3 ms·
Would you be ok with history rewriting in feature branch prior to merge? Seems like potentially best of both worlds.
by ivalm 5y ago
Would you be ok with history rewriting in feature branch prior to merge? Seems like potentially best of both worlds.
- rectang 5y agoI 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.
- vtbassmatt 5y ago`git commit --fixup` and `git rebase --autosquash` automate a bit of the drudgery for this workflow. Sharing because I just got introduced to them recently.