Let’s walk through the life of a code review together, and while we do so I’d like to show you two ways to view that lifecycle.
A junior dev, Bob, pulls the main branch (formerly known as the master branch) and creates his own branch, at commit beef...
:
Bob$ git pull
Bob$ git checkout -b bob/featureBob
Bob$ git rev-parse HEAD
beef...
He then makes some changes using my favorite editor:
Bob$ vim path/to/project/filename.py
And now he’s ready to commit his changes:
Bob$ git add path/to/project/filename.py
While Bob takes his time, Alice does the same, but then commits her changes and pushes her branch, and makes a PR all at once:
Alice$ git pull
Alice$ git checkout -b alice/featureAlice
Alice$ git rev-parse HEAD
beef...
Alice$ vim path/to/project/filename.py
Alice$ git commit !$ -m "New feature A"
git commit path/to/project/filename.py -m "New feature A"
Alice$ git push --set-upstream origin alice/featureAlice
Alice$ gh pr create
At this point, their code is on a collision course. Whoever gets their change in first, is potentially going to cause merge conflicts in the other’s PR. Since Alice seems to be the quicker engineer, we’re going to assume she gets her change in soon:
Alice$ gh pr merge --rebase
Bob, however, doesn’t merge or rebase the main branch yet. He’s going to send his code out for review as-is to Carol:
Bob$ git commit -m "New feature B"
Bob$ git push --set-upstream origin bob/featureBob
Bob$ gh pr create --reviewer carol-on-github
Carol sees a new, seemingly-unreviewed PR:
When Carol sees Bob’s PR, it will include a single commit based on what HEAD was, beef...
and that’s what she reviews as well. But then, when Carol leaves her review, she notices the warning that the PR can’t merge cleanly, so she leaves a comment for Bob to update:
Bob$ git fetch origin main
Bob$ git rebase origin/main
...snip merge conflict resolution...
Bob$ git push --force
When Carol views this PR again, she could use either code review tool available to her. This is where we come to a fork in the road.
What Carol would see in GitHub: Commits
Let’s take the well-traveled path now, and see what GitHub shows us: commits.
Carol sees a familiar PR, but it’s a