This blog has been moved to

Friday, May 13, 2011

Some useful git aliases

Git aliases are a great way to do more with less typing. Our team uses submodules to an extent which can sometimes be confusing. Some of these aliases help to clarify behavior. These are a few of my favorites.

git lg

This gives you a nicely formatted semi-graphical log view with users, branches, and remotes

git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %C(green)%an%Creset %Cgreen(%cr)%Creset' --abbrev-commit --date=relative" 

git latest

This does a git pull on the current repository as well as all submodules

git config --global alias.latest '!sh -c "git pull && git submodule foreach \"git pull\""'

git virgin (getting to a pure state)

This will reset your changes and delete all untracked and ignored files (includes bin/ and obj/ directories)

git config --global '!sh -c "git reset HEAD --hard && git clean -fXd && git clean -fd"'

git harem (a whole lot of virgins)

This does a virgin for your repository as well as all submodules

git config --global alias.harem '!sh -c "git virgin && git submodule \"git harem\""'

No comments:

Post a Comment