git squash commits
Add the below to your .bashrc
or similar :
function gsq(){
git reset --soft HEAD~$1 && \
git commit --edit -m \
"$(git log --format=%B --reverse HEAD..HEAD@{1})"
}
then you can use gsq 3
to squash the last three commits to one.
Written by hemanth
Related protips
3 Responses

I think the correct syntax for this function declaration should be function gsq()
You want to get only the first parameter anyway...
over 1 year ago
·

Heh heh right, I'm using $1 anyway :)
over 1 year ago
·

Seems there would be a way to put this in as a git alias (like the popular 'lg' one).
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Cli
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#