

Depending on how the fault config is set, you may encounter the following. Now merge the changes from upstream/master into your local master branch. An upstream branch is a remote branch that is being tracked by a local branch. This is shown by the output of the git status command, which shows the submodule is modified, and has new commits.
#Git fetch upstream update
However, it does not update the submodules. git fetch upstreamĬheck out the master branch from your local fork. By default, the git pull command recursively fetches submodules changes, as we can see in the output of the first command above. Your commits to master will be stored in the local branch upstream/master. Upstream (push) Catching up a git fork to masterįetch project branches from the upstream repository to get all the commits.

You can verify that all went well: git remote -v
#Git fetch upstream how to
You only need to do this once: Add a new remote upstream repository to sync with the fork where ORIGINAL_OWNER is the original GitHub account and ORIGINAL_REPOSITORY is the original repository name. Date Published: A couple of years ago, I wrote an article on how to use the git command line to sync a fork with its upstream branch. Open a command line prompt and change the current directory to your project’s directory. Design: Behind Prototype Scenario 2: Sync when 2 commits ahead, 10 commits behind upstream Performs fast-forward merge and upon completion, an alert is shown to indicate sync success. Then you can catch up that fork to the current master. Scenario 1: Sync when 10 commits behind upstream Performs fast-forward merge and upon completion, an alert is shown to indicate sync success. First, you must configure a git remote for a fork. You’ll also need a git command line tool. Compare the Git fetch vs Git pull actions and when you should use which command to get changes from your remote repository, and get a refresher on how to.

In this post, I’ll assume you are using master. Some development workflows will use a different branch than master for day-to-day development but the same steps apply using whatever that branch name is. The first thing I need to do is to catch up my git repository to whatever the current code is in the master branch of the original repository. Use git fetch to retrieve new work done by other people.
#Git fetch upstream Patch
If I do not, the project I want to contribute to might not be able to apply my patch or merge my pull request cleanly. I have a patch to contribute, or a bug to fix but I want to make sure that my local copy of the repository is not stale. Here I am in one of my forked git repositories on GitHub.
