Skip to content

Instantly share code, notes, and snippets.

@henriquemenezes
Last active April 29, 2016 00:43
Show Gist options
  • Save henriquemenezes/d0cbef1a6b3b28f6f33b545e3f839af2 to your computer and use it in GitHub Desktop.
Save henriquemenezes/d0cbef1a6b3b28f6f33b545e3f839af2 to your computer and use it in GitHub Desktop.
Syncing a fork

Syncing a fork

Sync a fork of a repository to keep it up-to-date with the upstream repository.

1. Configuring a remote for a fork

List the current configured remote repository for your fork.

git remote -v

Specify a new remote upstream repository that will be synced with the fork. (track)

git remote add upstream [email protected]:ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git

Verify the new upstream repository you've specified for your fork.

git remote -v

2. Update upstream repository

Fetch the branches and their respective commits from the upstream repository. Commits to master will be stored in a local branch, upstream/master.

git fetch upstream
git checkout master

Now we have two options to update local branch master.

  • Merge changes from upstream/master into master brach
  • Rebasing master branch from upstream/master (cleaner history)

Merge from upstream/master

git merge upstream/master

Rebase from upstream/master

git rebase upstream/master

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment