Github forking after cloning

When you want to change/contribute to other people’s projects that you don’t have access to you usually fork the project, and then use your read+write fork.

What if you first cloned their repo and made local commits that you now want to contribute? You don’t want to mess with patches, so here’s what I did to contribute a small fix to the example project from Apache Maven 2 Effective Implementation, a great book by Brett Porter and Maria Odea Ching.

  1. Fork the project repo at Github (at https://github.com/brettporter/centrepoint/)
  2. In my local clone, I renamed the remote origin to upstream
  3. Add a new remote called origin pointing to the read+write fork
  4. Change the master branch remote to origin instead of upstream
  5. Fetch the remote and push your changes
git remote rename origin upstream
git remote add origin [email protected]:carlossg/centrepoint.git
git fetch origin
git branch --set-upstream master origin/master
git push origin

3 thoughts on “Github forking after cloning

  1. “`git branch –set-upstream master origin/master“` is no longer supported. Instead use “`git branch –set-upstream-to origin/master master“`

Leave a reply to Matteo Cancel reply