Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
$ which git
/cygdrive/c/git-1.7.10/bin/git
$ git --version
git version 1.7.10.msysgit.1

 

Tips and Tricks

This is a compilation of some potentially useful git commands and/or aliases

 

1) Command Line commit graph

This is a nifty little command-line for displaying all of a repository's history in a pretty way from a terminal

Code Block
git log --graph --full-history --all --color --pretty=tformat:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s%x20%x1b[33m(%an)%x1b[0m"

you can also create an alias for this:

Code Block
git config alias.gr 'log --graph --full-history --all --color 
    --pretty=tformat:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s%x20%x1b[33m(%an)%x1b[0m"'

Run git config --global ... if you want this alias available in all of your repositories (instead of just the one you happen to be in currently).  Now all you have to type is git gr

 

2) Ignoring local changes to a tracked repository file

For example, if you have changed the pom.xml of your maven project to depend on a SNAPSHOT of the main PLFM libraries, or some other local change that you shouldn't ever check in to the main repository.  Read more about it on this blog.

Code Block
git update-index --assume-unchanged FILENAME

To make the changes to the file noticed by git again:

Code Block
git update-index --no-assume-unchanged FILENAME

PITFALL - must be run against every new checkout of the repository.  I'm not sure if this means when you swap branches, but I suspect it may.