DEV Community

Benji πŸ™
Benji πŸ™

Posted on

TIL you can apply git fixup automatically with git absorb

One thing to be clear is that git absorb is not an official command , at least not with version 2.39.2 which is what I'm using.

The idea is, if you've ever used git fixup you'll likely be aware you have to do something like this:

git add <my file>
git commit --edit --fixup <commit SHA>

# And then rebase to keep your commit history clean and atomic
git rebase --autosquash --interactive origin/master
Enter fullscreen mode Exit fullscreen mode

What this guy does, is it will automatically find the correct commit SHA for you, and automatically if you append --and-rebase

The result is your commit history looks and reads like a book:

commit 2: Feature B
commit 1: Feature A
Enter fullscreen mode Exit fullscreen mode

instead of:

commit 3: linting issue for Feature A
commit 2: Fix bug for failing test for Feature A
commit 2: Feature B
commit 1: Feature A
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Retry later
Retry later