How can I show the name of branches in `git log`?

Git

Git Problem Overview


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.

Git Solutions


Solution 1 - Git

Try the decorate option.

git log --graph --all --decorate

It annotates commits which are pointed to by tags or branches.

Solution 2 - Git

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
Another useful answer: https://stackoverflow.com/questions/13954376/how-to-show-git-log-with-branch-name/13955891

Solution 3 - Git

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionvdboorView Question on Stackoverflow
Solution 1 - GitCB BaileyView Answer on Stackoverflow
Solution 2 - GitAndroid ControlView Answer on Stackoverflow
Solution 3 - GitSimonView Answer on Stackoverflow