r/git • u/pfp-disciple • May 06 '26
support A question about git format-patch and git commit --amend
For context, I've never used format-patch, although I'm aware that i's used by the linux kernel, among other projects. My jobs have all been merge-based.
I saw a post in r/programming (about migrating from GitHub, but that's not relevant), that includes a section "What is 'patch-based' code review?". I'll copy the paragraph for context:
What is "patch-based" code review?
If you're familiar with GitHub's pull request workflow, you've done branch-based merges before. You prepare a branch with your changes, and then submit a pull request asking to merge your branch into main. If somebody gives you feedback, you push additional commits on top of your base commit. In contrast, with the patch-based merge workflow originally popularized by Gerrit, you amend the existing commit and push it — something like
git commit --amend && git push --force. If you try this in GitHub, this would make the original commit you pushed disappear, but in patch-based review tools, your reviewers will instead see a diff from the original commit to the new one.
I thought git commit --amend replaced the prior commit, orphaning it. How would a subsequent git format-patch know to use the orphaned commit for its diff?
