Syncing a fork branch from the command line on GitHub

Syncing a fork branch:

Before you can sync your fork with an upstream repository, you must configure a remote that points to the upstream repository in Git. To sync an fork branch fetch the branches and their respective commits from the upstream repository. 

Note: Commits to somebranch will be stored in the local branch upstream/somebranch

fetch the branches and their respective commits from the upstream repository using git fetch upstream

git fetch upstream

Then check out your fork's local default branch - In mine case I will use master.

git checkout master

Merge the changes from the upstream default branch - in this case, upstream/master- into your local default branch. This brings your fork's default branch into sync with the upstream repository, without losing your local changes.

git merge upstream/master

If your local branch had unique commits, you may need to resolve conflicts.


Tags:

git

Share:

Related posts