Skip to content

Rebasing clang format commits with git absorb

Enrico Seiler edited this page May 25, 2022 · 1 revision

If you want to incorporate the format changes, we recommend using git absorb: https://github.com/tummychow/git-absorb

git absorb distributes staged changes to existing commits. The verbose workflow could look like this:

git pull # pull formatting changes
git reset --soft HEAD~1 # reset index to before the formatting changes, edited files are staged
git absorb # run git absorb
git log # check the auto-generated fixup commits
git rebase -i --autosquash master # replace master with the branch you branched from if it was not master
git push -f # force push updates

A shorter, but potentially with unintended squashes, version is:

git pull # pull formatting changes
git reset --soft HEAD~1 # reset index to before the formatting changes, edited files are staged
git absorb --and-rebase master # run git absorb and rebase on master, replace master with the branch you branched from
git push -f # force push updates
Clone this wiki locally