Most of you Git users probably already know about Git aliases. Typically you add a few lines to ~/.gitconfig and you can alias
git co to
git checkout, etc:
[alias] co = checkout st = status ci = commit
But you can also use it to run shell commands by prefixing the alias with an exclamation mark (!), my first of which was aliasing
git df to
git diff | mate to pipe the diff into TextMate, which gives me pretty colors and a familiar environment:
df = !git diff | mate
Mostly I’m just lazy. I’d prefer to type
git save mystashname instead of
git stash save mystashname, and
git pop instead of
git stash pop, because I find myself stashing a lot of stuff and like to give them proper names, etc etc. It’s totally awesome that I can make Git work for me.
The most crazy one I’ve been experimenting with so far wraps up a common pattern I have, which is…
- switching back to the master branch from my generic “dev” branch
- pulling from the remote
- switching back to “dev”
- rebasing “dev” against “master”
- switching back to “master”
- merging in the changes from “dev”
- and finally running git wtf to show me what all my branches look like after the merge before I do a push.
I call this
publish = !git checkout master && git pull && git checkout dev && git rebase master && git checkout master && git merge dev && git wtf
Get lazy! Go make Git and bash do the hard work for you!