Search code examples
gitversion-controlcommitgit-commitgit-revert

Coalescing adjacent commit and its revert


I have a peculiar commit log which looks like that,

A --> B --> C --> D

where each letter is a commit. It appears that C is a revert of B, so basically the history would be the same as

A --> D

Is there a way to "sum" the B and C commits ? The changes haven't been pushed yet.


Solution

  • You can do git rebase -i HEAD~3 and remove the lines representing the B and C commits in the TODO list and do the rebase.