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
- git clone the remote (“upstream”) repo locally;
- push that clone to my own origin;
- branch off my local (while keeping my origin up-to-date);
- 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.