Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display the tag name and branch name using git log --graph

Tags:

git

I am using gitk --all to view the git log. gitk does not display the sha hash for each commit. you need to manually click on the commit to view the sha hash. I want to see the sha hash and the branch name in a single view.

How to display the tag-names and branch names using the git log command.

like image 811
Talespin_Kit Avatar asked Aug 11 '11 08:08

Talespin_Kit


People also ask

What does the command git log Oneline graph do?

git log by default shows the entire ancestry in order by birthdate (where timestamp weirdities don't make that contradict ancestry). Try it with git log --oneline --graph --decorate --first-parent . ^ or ^1 means the first parent.

Does git log show all branches?

Log tab This tab is only available if you are using Git or Mercurial for version control. This tab shows all local and remote branches, and all changes committed to all branches, or to a specific branch or repository.


1 Answers

With git log (so, not gitk), you can use the decorate option (%d) in a pretty format, for displaying the branch name (but only for commits which are the HEAD of said branches):

alias.lgb=log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset%n' --abbrev-commit --date=relative --branches

(you have to declare that alias with:

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

Then you can use it with 'git lgb'. Note: you can name it with a different alias. )

Will give:

* e33afe7 - (HEAD, master) fix zlib make install issue on cygwin (8 seconds ago) <VonC>
|
* f825f36 - add CPPFLAG option for cygwin compilation of gcc (26 hours ago) <VonC>
|
* 9341979 - (origin/master, origin/HEAD) update error messages for compiling gcc within cygwin (2 days ago) <VonC>
|
* 42d81af - copy dll in $H/usr/local/bin instead of linking when compiling in cygwin (3 days ago) <VonC>

Update Git 2.2 (November 2014): see commit 9271095 from Harry Jeffery (eXeC64):

pretty: add %D format specifier

Add a new format specifier, '%D' that is identical in behaviour to '%d', except that it does not include the ' (' prefix or ')' suffix provided by '%d'.

like image 86
VonC Avatar answered Sep 24 '22 11:09

VonC