Last active
December 1, 2023 10:58
-
-
Save philipstanislaus/88cea550a29c332e39a120f8b2d904fd to your computer and use it in GitHub Desktop.
Create empty git base commit for a full code review
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create empty base commit that will be the reference for our code review | |
git checkout --orphan base | |
git rm -r --cached . | |
git clean -fxd | |
git commit --allow-empty -m "Start of the review" | |
# create and checkout review branch that will include the latest code that should be reviewed | |
git checkout -b review | |
# merge main branch into that new review branch | |
git merge main --allow-unrelated-histories --no-edit | |
# for a detailed explanation https://astrofrog.github.io/blog/2013/04/10/how-to-conduct-a-full-code-review-on-github/ |
Use the following to create a new commits with updates to the codebase that should be reviewed. This ensures the updates are theirs
only.
# create and checkout updates branch that will contain new updated code that should be reviewed
git checkout -b updates
# merge changes from branch with code that should be reviewed (assuming `main` here), but without conflicts, the contents of 'ours' will be discarded later
git merge -s ours main --no-edit
# make temporary branch to merged commit
git branch temp
# get contents of working tree and index to the one of main
git reset --hard main
# reset to our merged commit but keep contents of working tree and index
git reset --soft temp
# change the contents of the merged commit with the contents of main
git commit --amend --no-edit
# get rid of our temporary branch
git branch -D temp
# verify that the merge commit contains only contents of main
git diff HEAD main
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Same as above as a one-liner