How to Git with Github

A few workflows I use for dealing with situations in ascending order of insanity

< all posts

Disclaimer: At the time of writing, the default Git branch name is still master so this post will use master instead of main. Hopefully I can come back and change that later once main (which seems to be gaining traction as the new standard) has become the default.

Git is a “sharp tool”. That’s software engineer speak for “I already learnt this, and now you need to”. Github doesn’t do an amazing job of taming it and, although Pull Requests are an important and valuable part of open source work, they can land you in even more treacherous waters.

I thought I’d write out a few workflows I use for dealing with situations in ascending order of insanity. This is as much a reference to myself as it might be for others. I’d advise going deeper on a lot the concepts mentioned here in the Git Book as I could well be wrong about everything.

Anyway, we’re going to start right at the beginning:

Starting work on your first PR for a project

Scenario:

Steps:

Creating a PR

Scenario:

Steps:

Starting work on a new PR

Scenario:

Steps:

Updating a PR when it has conflicts with master

Scenario:

Steps:

OK those are the “basics”. The next section is mainly going to deal with “dependent PRs” - when you have one pull request that uses a feature branch that is based off another feature branch rather than master. You should avoid this at all costs, but sometimes it’s necessary when working on dependent changes while earlier ones are reviewed.

Updating dependent PR after original merged to master

Scenario:

Steps:

Updating dependent PR once original changed

Scenario:

Steps:

Updating dependent PR after original is rebased

Scenario:

Steps:

Updating dependent PR after original merged as a single commit (squashed)

Scenario:

Steps:

And as a bonus, here’s a scenario you’ll only realy run into when maintaining a project. Be warned - it’s shenanigans:

Creating a hotfix from a set of specific merged PRs

Scenario:

Steps: