如何在`git log`中显示分支名称?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1841405/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I show the name of branches in `git log`?
提问by vdboor
How can I show the name of branches in the output of git log
?
如何在输出中显示分支的名称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 log --graph --all
我对提交有一个很好的概述,但很困惑哪一行是主,哪一行是我的分支。
回答by CB Bailey
Try the decorate option.
尝试装饰选项。
git log --graph --all --decorate
It annotates commits which are pointed to by tags or branches.
它注释由标签或分支指向的提交。
回答by Android Control
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)
我正在调查blackbox
加密的风险,admins
当足够多的用户离开项目并且keyrings
目录没有严格地基于 master时,repo 及其分支/标签可能变得不可用)
I found that the answer below was helpful where the keyrings
directory was not updated from master...
我发现下面的答案在keyrings
目录未从 master 更新的情况下很有帮助...
Basically adding --source
was what I needed to show the branches/tags. Adding --name-only
will also show which file was actually changed.
基本上添加--source
是我需要显示的分支/标签。添加--name-only
还将显示实际更改了哪个文件。
cd /path/to/repo-that-uses-blackbox-encryption
git log --graph --all --decorate --source --name-only keyrings
Another useful answer: How to show git log with branch name
另一个有用的答案:How to show git log with branch name
回答by Simon
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.
如果你碰巧使用 oh-my-zsh 作为你的终端,那么有一堆 git 别名可用。所有这些都可以在他们的 repo oh-my-zsh/plugins/git 中看到。如果您不使用此终端,那么您只需获取别名并将您喜欢的别名粘贴到您自己的环境中即可。
The accepted answer presents the git log --graph --all --decorate
command, which is available as the glgga
alias in oh-my-zsh.
接受的答案提供了git log --graph --all --decorate
命令,该命令可用作glgga
oh-my-zsh 中的别名。
Personally I prefer the glods
alias which translates to:
就个人而言,我更喜欢glods
别名,它可以翻译为:
git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short