Skip to content

Instantly share code, notes, and snippets.

@macghriogair
Created March 27, 2019 12:02
Show Gist options
  • Select an option

  • Save macghriogair/06ea8d080d67fc2b868f3edf2e4afb5e to your computer and use it in GitHub Desktop.

Select an option

Save macghriogair/06ea8d080d67fc2b868f3edf2e4afb5e to your computer and use it in GitHub Desktop.
[git sync fork] #git #fork

Sync a fork or a repository to stay up to date with upstream

cf. https://help.github.com/en/articles/syncing-a-fork

list remotes

git remote -v
origin	https://github.com/macghriogair/bitbucket-push-and-pull-request-plugin.git (fetch)
origin	https://github.com/macghriogair/bitbucket-push-and-pull-request-plugin.git (push)
upstream	https://github.com/jenkinsci/bitbucket-push-and-pull-request-plugin.git (fetch)
upstream	https://github.com/jenkinsci/bitbucket-push-and-pull-request-plugin.git (push)

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

Check out your fork's local master branch.

git checkout master

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

git merge upstream/master

Push changes to fork

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