Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable Git's autosquash feature by default.
Autosquash makes it quicker and easier to squash or fixup commits during an interactive rebase. It can be enabled for each rebase using `git rebase -i --autosquash`, but it's easier to turn it on by default. Say I have this history: $ git log --oneline aaa1111 A first commit bbb2222 A second commit ccc3333 A third commit I make another change that I already know should be squashed into "A second commit". I can do this: $ git add . $ git commit --squash bbb2222 [my-branch ddd4444] squash! A second commit Then when I rebase: $ git rebase -i origin/my-branch The interactive rebase list will be set up ready to squash: pick aaa1111 A first commit pick bbb2222 A second commit squash ddd4444 squash! A second commit pick ccc3333 A third commit Since it's unlikely that anyone will be writing a commit message that begins `squash!` or `fixup!` when they don't want this behaviour, and the user still has a chance to review what's going to happen with the rebase, it's safe to have it always turned on.
- Loading branch information
ed6f009
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoa this is awesome! thanks for the nice writeup in the commit message
ed6f009
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for the commit message!
ed6f009
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've seen this commit getting passed around and tweeted quite a bit, so I expanded the message into a more detailed blog post: https://robots.thoughtbot.com/autosquashing-git-commits
ed6f009
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@georgebrock is there an easy way to make a
fixup
commit? I've seen one described in a blogpost, let me see if I can dig it up.Yup, here we go...
https://technosorcery.net/blog/2010/02/07/fun-with-the-upcoming-1-7-release-of-git-rebase---interactive---autosquash/
ed6f009
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@georgebrock oh it looks like git has this built in now. Maybe I missed this... disregard [:
I should have read your article first!