Search code examples
gitbranchgit-tag

How to build a tag tree in GIT?


As frequent GIT user, I love git log --graph as much as I love git tag. I was made responsible for a large GIT repository with too many branches and tags and I am proceeding too slowly with the sisyphusian work of reducing those numbers.

It would be extremely helpful is to have a tag tree graph, just like a usual commit graph, but only with those branches which have tags on it. I would also need the hash of each tagged commit (and ideally also the time-stamp and author).

I searched a lot, but I never found anything like what I described.

Some references (of ever so many)


Solution

  • As Amadan pointed out, I should have dived deeper into the git-log documentation in the most recent version. The solution is simply to include the --simplify-by-decoration flag. Altogether, I ended up with the following

    git log --graph --simplify-by-decoration --pretty=format:'%C(yellow)%h %ad %an%Cgreen%d %Creset%s' --date=short
    

    The official formatting documentation explains all the details of --pretty=format:'...', the most important parts are

    • %h = abbreviated commit hash
    • %an = author name
    • %ad = author date
    • %s = subject

    If want something to memorize, just use

    git log --graph --simplify-by-decoration
    

    This gives you an output without of commit hash and git-tag only.