Created
January 25, 2012 22:51
-
-
Save zettoone/1679425 to your computer and use it in GitHub Desktop.
git tricks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A few `git log` commands where things are nicely aligned | |
# from http://pyrtsa.posterous.com/aligning-your-git-logs and https://gist.github.com/1327258 | |
# Dependent on Gawk (brew install gawk in OsX) | |
[alias] | |
l50 = "!f () { git log --abbrev-commit --date=short --pretty=format:'%h%x00%cd%x00%s%x00%an%x00%d' $@ | gawk -F '\\0' '{ printf \"\\033[31m%s\\033[0m \\033[32m%s\\033[0m %-50s \\033[30;1m%s\\033[0m\\033[33m%s\\n\", $1, $2, gensub(/(.{49}).{2,}/, \"\\\\1…\",\"g\",$3), $4, $5 }' | less -R; }; f" | |
l80 = "!f () { git log --abbrev-commit --date=short --pretty=format:'%h%x00%cd%x00%s%x00%an%x00%d' $@ | gawk -F '\\0' '{ printf \"\\033[31m%s\\033[0m \\033[32m%s\\033[0m %-80s \\033[30;1m%s\\033[0m\\033[33m%s\\n\", $1, $2, gensub(/(.{79}).{2,}/, \"\\\\1…\",\"g\",$3), $4, $5 }' | less -R; }; f" | |
lg50 = "!f () { git log --graph --color=always --abbrev-commit --date=relative --pretty=format:'%x00%h%x00%s%x00%cd%x00%an%x00%d' $@ | gawk -F '\\0' '{ printf \"%s\\033[31m%s\\033[0m %-50s \\033[32m%14s\\033[0m \\033[30;1m%s\\033[0m\\033[33m%s\\n\", $1, $2, gensub(/(.{49}).{2,}/, \"\\\\1…\",\"g\",$3), $4, $5, $6 }' | less -R; }; f" | |
lg80 = "!f () { git log --graph --color=always --abbrev-commit --date=relative --pretty=format:'%x00%h%x00%s%x00%cd%x00%an%x00%d' $@ | gawk -F '\\0' '{ printf \"%s\\033[31m%s\\033[0m %-80s \\033[32m%14s\\033[0m \\033[30;1m%s\\033[0m\\033[33m%s\\n\", $1, $2, gensub(/(.{79}).{2,}/, \"\\\\1…\",\"g\",$3), $4, $5, $6 }' | less -R; }; f" | |
# new version | |
lg80 = "!git log --graph --color=always --abbrev-commit --date=relative --pretty=format:'%x00%h%x00%s%x00%cd%x00%an%x00%d' | gawk -F '\\0' '{ printf \"%s%*s\\033[31m%s\\033[0m %-80s \\033[32m%14s\\033[0m \\033[30;1m%s\\033[0m\\033[33m%s\\n\", $1, 10-length(gensub(/[^ |\\\\\\/*]/,\"\",\"g\",$1)), \" \", $2, gensub(/(.{79}).{2,}/, \"\\\\1…\",\"g\",$3), $4, $5, $6 }' | less -R" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# some tricks from http://gitimmersion.com/lab_10.html | |
git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short | |
# texture output | |
git log --graph --oneline --all | |
# better look of git log | |
# from http://www.theint.ro/blogs/outro/4649682-git-for-busy-people-see-what-youre-doing | |
git log --graph --pretty="format:%C(yellow)%h%Cblue%d%Creset %s %C(white) %an, %ar%Creset" | |
# create a graph command | |
git config --global alias.graph 'log --graph --all --oneline --decorate --color --date-order' | |
# some aliases from https://github.com/jphenow/dotfiles/blob/master/git/aliases.bash | |
alias gl='git pull --prune' | |
alias glog="git log --graph --pretty=format:'%Cred%h%Creset %an: %s - %Creset %C(yellow)%d%Creset %Cgreen(%cr)%Creset' --abbrev-commit --date=relative" | |
alias gp='git push origin HEAD' | |
alias gd='git diff' | |
alias gc='git commit' | |
alias gca='git commit -a' | |
alias gco='git checkout' | |
alias gb='git branch' | |
alias gs='git status -sb' # upgrade your git if -sb breaks for you. it's fun. | |
alias grm="git status | grep deleted | awk '{print \$3}' | xargs git rm" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment