How can I show the name of branches in the output of git log
?
For example with, git log --graph --all
I get a nice overview of the commits, but get confused which line is master, and which is my branch for example.
Join Stack Overflow to learn, share knowledge, and build your career.
How can I show the name of branches in the output of git log
?
For example with, git log --graph --all
I get a nice overview of the commits, but get confused which line is master, and which is my branch for example.
Try the decorate option.
git log --graph --all --decorate
It annotates commits which are pointed to by tags or branches.
git log --graph --all --oneline --decorate
. I have an alias git graph
that uses --pretty
(in order to show other stuff as well, such as author and date), but %d
there does not give me the colors of --decorate
. I use yellow for all my refs for now, do you know how I can let --pretty
's %d
string inherit the colors of --decorate
?
– Gauthier
Mar 18 '15 at 14:11
--pretty
formats, add %C(auto)
before the element what should be coloured. e.g. git log --pretty=format:"%cd %h %cn %s %C(auto)%d"
– Radon8472
Feb 5 '18 at 9:11
I was looking for something similar to this - but wanted to know what branch a change was made. Hopefully this answer will be of use to others also.
I'm investigating a risk with blackbox
encryption, where a repo and it's branches/tags may become unavailable to current admins
when enough users leave a project and the keyrings
directory has not been religiously based off of master)
I found that the answer below was helpful where the keyrings
directory was not updated from master...
Basically adding --source
was what I needed to show the branches/tags. Adding --name-only
will also show which file was actually changed.
cd /path/to/repo-that-uses-blackbox-encryption
git log --graph --all --decorate --source --name-only keyrings
--source
alone gives HEAD
for all commits. In combination with --all
, this seems to distinguish between different branches, but the displayed information is not what I expect: for commits I did in master
, instead of getting refs/heads/master
, I get some private branch (refs/remotes/origin/…
). I suspect that merges and/or new branches make Git
lose history information.
– vinc17
May 10 '20 at 17:36
--all
, I can filter on the branches with --branches --remotes=<pattern>
, but as soon as two branches are merged together, Git no longer has the information on which one had the commit when it was done.
– vinc17
May 10 '20 at 17:55
If you happen to be using oh-my-zsh as your terminal then a bunch of git aliases are available. All of which can be seen at their repo oh-my-zsh/plugins/git. If you don't use this terminal, then you just can grab the aliases and paste the ones you like into your own environment.
The accepted answer presents the git log --graph --all --decorate
command, which is available as the glgga
alias in oh-my-zsh.
Personally I prefer the glods
alias which translates to:
git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short
git
update. – underscore_d Aug 2 '17 at 10:29