User:PEZ/Git things

From Robowiki
< User:PEZ
Revision as of 11:44, 13 November 2011 by PEZ (talk | contribs) (My git solutions log (mostly for my own memory, but feel free to use and contribute))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Thought I could use a wiki page here as a solutions log for git tricks I stumble across.

Resources

The Git Pro book and site has been absolutely invaluable to me to get rid of the feeling that Git always surprises me. http://progit.org/ I have the .epub on both my iPhone and iPad.

A few days ago I found this really cool site about figuring git out: http://think-like-a-git.net/ It's really fun to read too.

Colors

Colored highlights help me a lot when trying to make sense of Git output. I have this in my ~/.gitconfig:

   [color]
     ui = true

Graph log

Yes, a GUI tool is often best to get an overview of the history. But I tend to stay at my prompt often and then this alias comes in handy:

   [alias]
     lg = log --graph --color --all --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative

(Add to your .gitconfig.)

Oneliners

(Of course, some of these can be turned into git aliases or functions in your shell if you find you use them often.)

git summary

A bit like hg summary.

   $ git log -1 --summary --stat

Undelete

You knew there was a file named foo.txt some time ago and want it back? Try this:

   $ git rev-list -n 1 HEAD -- foo.txt
   b193eecf895e45b4f875eb4e6030f2c2e9fac897
   $ git checkout b193eecf895e45^ -- foo.txt