UP | HOME

git-more

Git Log

git log –stat

Show statistics of number lines added and deleted.

https://lh6.googleusercontent.com/-jaNagkLs3rU/Tu-DuIZKN1I/AAAAAAAACaE/xdNCDuVv6Vw/s800/git-log--stat.jpg

git log –since="3 weeks ago" –until="yesterday"

Show the commits for a time period

git log -p

Show patches of the commits

https://lh5.googleusercontent.com/-iULY5TLtYaw/Tu-D5rVPdGI/AAAAAAAACZw/U1Cr0Vh09Ao/s800/git-log-p.jpg

git log –graph

Prints a graph on the side to show branches

https://lh4.googleusercontent.com/-y3F733L3w9w/Tu-KMcMnp7I/AAAAAAAACac/YtfG0oN5kaU/s640/git-log-stat-graph-pretty-short.jpg

The stars in the graph show which branch the commits are on. The full command for the above output is:

git log --graph --stat --pretty=short

The repository used is the repository of git itself. You can clone the repo yourself with:

git clone git://github.com/gitster/git.git

The repositories used above are from drupal. Clone Drupal-core with:

git clone --branch 7.x http://git.drupal.org/project/drupal.git

Git Show

Show a particular commit with git show

git show HEAD^^^

It will show the entire commit as a diff.

Set git to output color

git config --local color.ui auto

This will add the following to your .gitconfig file:

[color]
       ui = auto

Git Bisect

Try to find where in the version history a bug first appeared.

# start bisect
git bisect start
# set good point: there was no bug here, this can be a tag, SHA1, or HEAD~18 ...
git good v1.2.6
# set bad endpoint: we know it had shown up by here
git bad master

# bisect will select a commit half way between good and bad
# test ... then tell git if its good or bad
git bisect good
# it will split the other half in half
git bisect bad
# when you've found the bad commit, reset the branch with
git biset reset