Git Squashit
A bash/zsh helper function to squash multiple Git commits.
Definition
function squashit () {
git reset --soft HEAD~$1 &&
git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})"
}
Usage
squashit <number_of_commits>
<number_of_commits>
: Number of recent commits to squash- Opens default text editor for commit message modification
Note
- Modifies Git history. Use cautiously.
- Best for combining small, ‘wip’ commits into a meaningful one.
- Consider creating a backup branch.