I have searched several times how to produce graph tree in terminal similar to Gitk or other GUI visualizers. Compiling the knowledge in this StackOverflow question together, I came up with the following command:
git log --graph --full-history --all --color --date=short --pretty=format:"%Cred%x09%h %Creset%ad%Cblue%d %Creset %s %C(bold)(%an)%Creset"
UPDATE: I added author name to the end of line in bold so that you can blame people quicker.
UPDATE 2: I changed the command to use Git color codes instead of ANSI to ease reading
This produces graph shown on the image.
(Unfortunately the %d
placeholder does not support separate colors for local and remote branches, as --decorate
itself does, which would be even better.)
To make it useful, I have aliased all of this for a much shorter command git tree
, which can be done with the following git config
line:
git config --global alias.tree 'log --graph --full-history --all --color --date=short --pretty=format:"%Cred%x09%h %Creset%ad%Cblue%d %Creset %s %C(bold)(%an)%Creset"'
NB! Notice the two sets of quatation marks.