DEV Community

Discussion on: What are your preferred bash aliases?

Collapse
 
nksprzak profile image
Nick Kasprzak

So my favorite is a git alias. When I have PR request open and I get comments on it and need to address them and then commit and rebase them.

The need for rebasing the last commit is to squash the fixing comments commit into the one that the PR is actually for, ie. Add some feature

I do this all the time and with git when you rebase it opens up your text editor so you can edit the commits you are rebasing to tell git whether you want to squash, drop, edit the commit messages.

I found it annoying that you have to manually type go down and change pick to s every time I had to address PR comments. So I found a Stack Overflow answer and turned that into this alias.

gg='ga && git commit --fixup=HEAD && GIT_SEQUENCE_EDITOR=: git rebase HEAD~2 -i --autosquash'

This improved my life a lot. Try it for yourself if you want and if anything gets messed up remember git reflog and git reset HEAD@{#} are your friends.