|
|
|
|
|
by rectang
1684 days ago
|
|
I do minor history rewrites on my feature branches all the time. 1. Fix typo or other small nit. 2. `git add -p` to add only the small change. 3. `git commit -m fixer` 4. `git stash` 5. `git log --oneline main..` and copy the SHA of the commit I want to fix. 6. `git rebase -i SHA~` 7. In the text editor launched by `rebase`, move the "fixer" commit after the one I want to modify. 8. For the `fixer` commit, change "pick" to "fixup". Save and quit, allowing the rebase to complete. 9. `git stash pop` This works most of the time, so long as the nit I want to fix isn't too far back in history. For those nits that aren't easy to fix with the workflow above, I just create an ordinary commit and leave it. It's annoying to have 5 "fixes lint error" commits in every feature branch, but it's fine to have them every once in a while. |
|