Let’s face it, Git is pretty raw, but it has the options to do cool stuff. That’s why I decided to make a post with the aliases I use all the time and couldn’t be without.

git lg

git log doesn’t do any good. It doesn’t list the branch the commit was made on, it doesn’t show colors and it doesn’t show branching visuals. But with this alias you get all that.

git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

Here is the plain old git log:

git log

Here you can see the lg alias in use:

git lg

git unpushed

Sometimes I wonder what is left to push to upstream. Git doesn’t have an easy way to see this, but with this alias you get the commits that haven’t been pushed to upstream. Also you get colors and branching visuals like above. Awesome!

git config --global alias.unpushed "log --branches --not --remotes --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

Here you can see the unpushed alias in use:

git unpushed

git undo

Git doesn’t have an undo option to undo the last commit. But with this alias you can easily undo the last commit.

git config --global alias.undo "reset --hard HEAD~1"

However if you’ve added many files in the last commit (like a package or something), git doesn’t delete them. But you can do that with this alias: git clean -f -d

Here you can see the undo alias in use:

git undo

Hope you enjoy this.