It is crucial to keep your GitHub forked repository in sync and make sure your forked repository is consistent with the latest changes from the original repository. This can be done by pulling changes from the original repository to the local repository and pushing it to the forked repository.
The process of updating a forked repository includes: forking the repository, cloning the forked repository, linking to the original repository, pulling changes from the original repository, and pushing changes to the forked repository. This process assumes that you have forked the repository and cloned the forked repository on your local machine.
When dealing with forked repositories, it is best to avoid committing changes directly to the main branch of the forked repository or the local repository. This branch should be used to save update code from the original repository only. All changes should be made in a new feature or error branch and pushed to a branch with the same name on the forked repository.
To understand the concept of updating a forked repository, you must first understand why this is necessary.
Organizations cannot grant write permissions to their primary repository to each potential contributor, so the public can only view the original repository. A fork is a copy of the original repository that a user can create. The user has read and write permissions for their own forks.
Usually, programming is done on a local machine (or virtual machine) rather than directly on the GitHub interface, so a clone of the forked repository is usually created.
Once the contributor submits a change to the local replica, it needs to be pushed to a forked repository on GitHub (this is possible due to write permissions). Then, create a pull request from the forked repository to the original repository.
Keep your forked repository up to date
When the original repository is updated with someone else's code (after the fork is created), these new commits will not automatically appear in the fork repository. These changes must first be downloaded and merged to the local repository and then pushed to the forked repository.
For historical reasons, in our local repository, we named the remote repository of the original repository upstream
and the forked repository origin
.
Ideally, you should never make any commits directly to the main branch of a forked repository or local repository. This branch must be used only to save update code from upstream
. All changes must be made in a new feature or error branch and pushed to a branch with the same name on the forked repository.
Therefore, the following steps help to update the forking repository with the latest commit from the original repository:
- Pull the main branch of the local repository from the main branch of
upstream
- Push from the main branch of the local repository to the main branch of the forked repository
These steps assume that you have forked the repository and cloned the forked repository on your local machine.
For demonstration, we will use the repository of e-Cidadania on GitHub.
Step 1: Fork the warehouse
To fork the repository, you need to click the fork button (the upper right corner of the screenshot).
Step 2: Clone your forked repository
To clone your forked repository, you first need to select the protocol from the drop-down menu (as shown in the screenshot below) and copy the link. In this demonstration, we will select the SSH protocol:
Open the terminal and run the following command:
git clone git@github.com:sdaityari/e-cidadania.git
Step 3: Link to the original repository
You then need to link your local repository to the original repository to be able to pull changes from the original repository. This is done by adding a upstream
remote repository. First, copy the SSH link from the original repository and add the remote repository by running the following command:
git remote add upstream git@github.com:cidadania/e-cidadania.git
To verify that the remote repository has been added, check the remote repository list by running the following command:
git remote -v
The output should look like this:
<code>origin git@github.com:sdaityari/e-cidadania.git (fetch) origin git@github.com:sdaityari/e-cidadania.git (push) upstream git@github.com:cidadania/e-cidadania.git (fetch) upstream git@github.com:cidadania/e-cidadania.git (push)</code>
Step 4: Pull changes from upstream
(original repository)
When there are new commits in the main branch of the original repository and there are no commits in your fork repository, you will receive a GitHub message on the fork repository's page. In the screenshot, you can see a message that says "This branch lags behind cidadania:master 36 commits":
To pull these changes to your local repository, run the following command:
git pull upstream master
This command will update your master branch from the upstream
remote repository.
Step 5: Push changes to origin
(forked repository)
To push these updates from the original repository to the forked repository, just run the following command:
git push origin master
To confirm that the changes have been updated, visit the forked repository page on GitHub again!
Message "This branch is consistent with cidadania:master" indicates that the main branch that has been added to the forked repository is changed.
FAQs (FAQs) on syncing GitHub fork repositories via command line
(The FAQ part is omitted here because it is too long and does not match the pseudo-original goal. The FAQ part can be reorganized and rewritten as needed, but the information must be ensured that the information is complete and the original intention is not changed.)
The above is the detailed content of Quick Tip: Sync a GitHub Fork via the Command Line. For more information, please follow other related articles on the PHP Chinese website!

The rise of Chinese women's tech power in the field of AI: The story behind Honor's collaboration with DeepSeek women's contribution to the field of technology is becoming increasingly significant. Data from the Ministry of Science and Technology of China shows that the number of female science and technology workers is huge and shows unique social value sensitivity in the development of AI algorithms. This article will focus on Honor mobile phones and explore the strength of the female team behind it being the first to connect to the DeepSeek big model, showing how they can promote technological progress and reshape the value coordinate system of technological development. On February 8, 2024, Honor officially launched the DeepSeek-R1 full-blood version big model, becoming the first manufacturer in the Android camp to connect to DeepSeek, arousing enthusiastic response from users. Behind this success, female team members are making product decisions, technical breakthroughs and users

DeepSeek released a technical article on Zhihu, introducing its DeepSeek-V3/R1 inference system in detail, and disclosed key financial data for the first time, which attracted industry attention. The article shows that the system's daily cost profit margin is as high as 545%, setting a new high in global AI big model profit. DeepSeek's low-cost strategy gives it an advantage in market competition. The cost of its model training is only 1%-5% of similar products, and the cost of V3 model training is only US$5.576 million, far lower than that of its competitors. Meanwhile, R1's API pricing is only 1/7 to 1/2 of OpenAIo3-mini. These data prove the commercial feasibility of the DeepSeek technology route and also establish the efficient profitability of AI models.

Midea will soon release its first air conditioner equipped with a DeepSeek big model - Midea fresh and clean air machine T6. The press conference is scheduled to be held at 1:30 pm on March 1. This air conditioner is equipped with an advanced air intelligent driving system, which can intelligently adjust parameters such as temperature, humidity and wind speed according to the environment. More importantly, it integrates the DeepSeek big model and supports more than 400,000 AI voice commands. Midea's move has caused heated discussions in the industry, and is particularly concerned about the significance of combining white goods and large models. Unlike the simple temperature settings of traditional air conditioners, Midea fresh and clean air machine T6 can understand more complex and vague instructions and intelligently adjust humidity according to the home environment, significantly improving the user experience.

Website construction is just the first step: the importance of SEO and backlinks Building a website is just the first step to converting it into a valuable marketing asset. You need to do SEO optimization to improve the visibility of your website in search engines and attract potential customers. Backlinks are the key to improving your website rankings, and it shows Google and other search engines the authority and credibility of your website. Not all backlinks are beneficial: Identify and avoid harmful links Not all backlinks are beneficial. Harmful links can harm your ranking. Excellent free backlink checking tool monitors the source of links to your website and reminds you of harmful links. In addition, you can also analyze your competitors’ link strategies and learn from them. Free backlink checking tool: Your SEO intelligence officer

DeepSeek-R1 empowers Baidu Library and Netdisk: The perfect integration of deep thinking and action has quickly integrated into many platforms in just one month. With its bold strategic layout, Baidu integrates DeepSeek as a third-party model partner and integrates it into its ecosystem, which marks a major progress in its "big model search" ecological strategy. Baidu Search and Wenxin Intelligent Intelligent Platform are the first to connect to the deep search functions of DeepSeek and Wenxin big models, providing users with a free AI search experience. At the same time, the classic slogan of "You will know when you go to Baidu", and the new version of Baidu APP also integrates the capabilities of Wenxin's big model and DeepSeek, launching "AI search" and "wide network information refinement"

This Go-based network vulnerability scanner efficiently identifies potential security weaknesses. It leverages Go's concurrency features for speed and includes service detection and vulnerability matching. Let's explore its capabilities and ethical

AI Prompt Engineering for Code Generation: A Developer's Guide The landscape of code development is poised for a significant shift. Mastering Large Language Models (LLMs) and prompt engineering will be crucial for developers in the coming years. Th


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Chinese version
Chinese version, very easy to use

Dreamweaver Mac version
Visual web development tools