Little Things I Like To Do in Git

Little Things I Like to Do with Git

Make your life easier when reviewing your Git repositories.

Here are a few Git tweaks to help your workflow.

Short Log
$ git shortlog -sn

$ git shortlog -sn --since='10 weeks' --until='2 weeks'

-- alias git stats
Git Blame
$ git blame -L5,10 _components.buttons.css

$ git config --global alias.praise blame

$ git praise -L18,23 _includes/head.html
Diff - Show Changed Words Instead of Whole Lines
$ git diff --word-diff
See Which Branches You Recently Worked On
$ git for-each-ref --count=10 --sort=-committerdate refs/heads/ --format="%(refname:short)"

See What Your Team Has Been Up To

$ git log -all --oneline --no-merges
Remind Yourself What You Have Been Up To
$ git log --all --oneline --no-merges --author=<your_email_address>

-- alias git recap
Today's Work
$ git log --since=00:00:00 --all --no-merges --oneline --author=<your email address>

--alias git today
Check Out What Your Are About to Pull
$ git log --oneline --no-merges HEAD..<remote>/<branch>

Example:

$ git checkout feature/fonts
$ git fetch
$ git log --oneline --no-merges ..origin/feature/fonts

--alias git upstream
Review What You Are About to Push
git log --oneline --no-merges <remote>/<branch>..HEAD  

Example:

$ git fetch
$ git log --oneline --no-merges origin/feature/fonts..HEAD

--alias git local
View Complex Logs
$ git log --graph --all --decorate --stat --date=iso

--alias git graph
View Pretty Logs
git log --oneline

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

Usage:

$ git lg -20

Craig Derington

Secular Humanist, Libertarian, FOSS Evangelist building Cloud Apps developed on Red Hat Enterprise Linux and Ubuntu Server. My toolset includes Python, Celery, Flask, Django, MySQL, MongoDB and Git.

comments powered by Disqus