Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

make git log --graph --all show current location like hg glog does

Tags:

git

logging

graph

How can I make git show my current node in the log graph? git log --graph --all marks all the nodes equally with *, but I'm used to Mercurial where hg glog visually differentiates my current node by depicting it with @. This is especially useful after git fetch (aka hg pull), when my current node won't necessarily be at the top.

Currently I have to figure out my current node's hash and then hunt through the output of graph log. Is there a better way?

PS - I'm in a non-graphical environment so gitk is not an option.

[UPDATE: now I'm fully acclimated to git, and the first thing I do setting up a new environment is issue the following command to setup a git alias:

git config --global alias.map 'log --graph --full-history --all --color --decorate'

This allows me to type git map in any repo and see an ascii-art map of all the branches and commits, and my location on that map. This alias is probably my single most-used git command at this point (besides add and commit), really indispensable for me]

like image 247
Magnus Avatar asked Nov 15 '11 13:11

Magnus


2 Answers

Adding the --decorate option will show the refs pointing to each commit. So, for example, you'll see HEAD and origin/HEAD (or whatever) in the right places.

They may even be in pretty colours if you have that enabled.

PS. thanks for making me check this - it's actually very nice, especially the way it also shows my various stashes.

like image 148
Useless Avatar answered Oct 23 '22 08:10

Useless


Maybe by adding some formatting option, you can see where HEAD is:

--pretty=format:"%h%x09%d%x20%s"

See "Visualizing branch topology in git" for illustration.

like image 25
VonC Avatar answered Oct 23 '22 08:10

VonC