Skip to content

Instantly share code, notes, and snippets.

@gfabrizi
Last active July 7, 2018 19:00
Show Gist options
  • Save gfabrizi/bd46308ca4c71f3869cd0cdc5920fc48 to your computer and use it in GitHub Desktop.
Save gfabrizi/bd46308ca4c71f3869cd0cdc5920fc48 to your computer and use it in GitHub Desktop.
git remote add upstream https://github.com/some_user/some_repo
git fetch upstream
git checkout master
git reset --hard upstream/master
git push origin master --force
Keep in mind, that this makes your repo look exactly like upstream - if you have commits, they will be eaten! If you want to update to upstream (but still keep your commits), you want git merge upstream/master. If you want to start a new patch based on upstream, the best way to do it is git checkout -b my-new-feature upstream/master
Of course, this all expects you have a remote named upstream, which you can create by doing git remote add upstream https://[upstream guy's repo url]
(Just to clarify, the term 'upstream' means the person you forked from)
`git push origin master --force` pushes back YOUR repo master branch.
See also:
https://stackoverflow.com/questions/9646167/clean-up-a-fork-and-restart-it-from-the-upstream/39628366
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment