I can never remember how to do this, so here, in a few lines is how to correctly set up a git fork to allow you to contribute to other people’s code
- At github fork the repository you are interested in. Sure, you can probably do this in the CLI, but why? In this example I am forking Bas Dutilh’s CAT repository
- clone your new fork somewhere to a CLI
- Set the upstream remote:
git remote add upstream https://github.com/dutilh/CAT.git
- Pull any changes since you did the fork (hopefully there aren’t any, but who knows)
git pull upstream master
- Push those to your branch
git push origin master
- Now maybe make a new branch to work on. This is just cleaner for later!
git checkout -b rob
… Do some work …
… Commit/push changes …
… Make a PR and merge …
- Delete the branch locally
git branch -d rob
[note if you have unmerged changes, you can add-f
to force this]
- Delete the remote branch
git push origin --delete rob