Git: Working with an Upstream Remote

In Software Engineering, Snippet

When I’m contributing to a project that I don’t have ownership of (and often even when I do), I often follow a fork-and-branch strategy. This means I

  1. git clone the remote (“upstream”) repo locally;
  2. push that clone to my own origin;
  3. branch off my local (while keeping my origin up-to-date);
  4. then open a pull request on the upstream repo when my branch is ready.

The downside to this, however, is that I need to keep my fork up-to-date with the upstream repo all the time. This means pretty regular rebasing, and at times, hard-resets to the “canonical” upstream master. Despite doing this all the time, I find that I constantly forget how to fetch/rebase, or fetch/reset. So here’s a cheatsheet.

Leave a Reply