Setting up a git fork

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

  1. 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
  2. clone your new fork somewhere to a CLI
  3. Set the upstream remote:
    • git remote add upstream https://github.com/dutilh/CAT.git
  4. Pull any changes since you did the fork (hopefully there aren’t any, but who knows)
    • git pull upstream master
  5. Push those to your branch
    • git push origin master
  6. 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 …

  1. Delete the branch locally
    • git branch -d rob [note if you have unmerged changes, you can add -f to force this]
  2. Delete the remote branch
    • git push origin --delete rob