git log without tags
Asked Answered
B

4

26

So I'm doing something like

 git log --graph --pretty='%h %d %s' -n10

to get brief history of my recent commits.

The only issue I have is that most of the time I'm not interested in seeing the tags, only the branches. %d however shows both tags and branches. Is there some way I can only display branch names and not tags?

Beaman answered 8/11, 2012 at 14:41 Comment(1)
Possible duplicate of Limit refs shown with git log --decoratePacifism
R
12

git log --format="%C(auto) %h %s"

enter image description here

Rottenstone answered 21/6, 2017 at 14:59 Comment(3)
I don't get it. The question asked for removing tags while keeping branch names. This also removes branch names.Rochkind
@Rochkind I clearly didn't read the question carefully. ¯_(ツ)_/¯ As far a I can tell, it is not possible to do exactly what the OP wanted.Rottenstone
https://mcmap.net/q/521764/-git-log-without-tags seems to be doing the jobTades
C
15

A bit late to the party, but I have just encountered the same issue.

This should display everything except tags:

git log --decorate-refs-exclude=refs/tags --pretty='%h %d %s' -n10
Colossian answered 21/2, 2022 at 3:48 Comment(0)
R
12

git log --format="%C(auto) %h %s"

enter image description here

Rottenstone answered 21/6, 2017 at 14:59 Comment(3)
I don't get it. The question asked for removing tags while keeping branch names. This also removes branch names.Rochkind
@Rochkind I clearly didn't read the question carefully. ¯_(ツ)_/¯ As far a I can tell, it is not possible to do exactly what the OP wanted.Rottenstone
https://mcmap.net/q/521764/-git-log-without-tags seems to be doing the jobTades
M
-2

add this to your .gitconfig

[alias]
        blog = log --graph --oneline --pretty=format:'%Cred%h%Creset - %C(yellow)%s%Creset %C(green)<%an>%Creset %C(blue)@%d%Creset' --abbrev-commit

This way you get only the commit number, message how made the commit and in which branch it was committed. and you only have to type git blog and you can look at colors when you want

and if you really only the branch name just do:

git log --graph --oneline --pretty=format:'%C(blue)@%d%Creset'

Marshmallow answered 8/11, 2012 at 15:34 Comment(9)
git log --graph --oneline --pretty=format:'%C(blue)@%d%Creset' still shows the tags too.Beaman
for k in git branch|perl -pe s/^..//;do echo -e git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k|head -n 1\\t$k;done|sort -rMarshmallow
@Beaman try git log --branches --remotes --tags --graph --oneline --decorateMarshmallow
I get a "syntax error near unexpected token '|'" and the 2nd one still shows tags...but I think I can possibly figure something out to remove them since they are now labeled "tag:"Beaman
@Beaman Like so for k in git branch|perl -pe s/^..//;do echo -e git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k|head -n 1\\t$k;done|sort -rMarshmallow
Yes starting with for k in.. and ending with |sort -r bash doesn't like it for some reason.Beaman
RHEL 5 gives the first error. On Debian I get something similar except the unexpected token is "do" and not "|"Beaman
@Beaman Okay how about this............... for k in git branch|perl -pe s/^..//;do echo -e git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k|head -n 1\\t$k;done|sort -rMarshmallow
@Beaman here look at this.Marshmallow
N
-3

Check out git log --help and specifically %d option:

%d: ref names, like the --decorate option of git-log(1)

This is your tags. So all you have to do is to drop it from your command, i.e.:

git log --graph --pretty='%h %s' -n10
Nicosia answered 15/1, 2020 at 17:54 Comment(1)
OP asked to keep branches, the above command removes them as well.Snakeroot

© 2022 - 2024 — McMap. All rights reserved.