简体   繁体   English

如何在`git log`中显示分支的名称?

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

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我可以很好地概述提交,但是混淆哪一行是master,哪个是我的分支。

Try the decorate option. 尝试装饰选项。

git log --graph --all --decorate

It annotates commits which are pointed to by tags or branches. 它注释标记或分支指向的提交。

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加密的风险,当有足够多的用户离开项目并且keyrings目录不是基于主人的宗教信仰时,当前admins可能无法使用回购及其分支/标签

I found that the answer below was helpful where the keyrings directory was not updated from master... 我发现下面的答案是有用的,其中keyrings目录没有从主人更新...

Basically adding --source was what I needed to show the branches/tags. 基本上添加--source是我需要显示分支/标签。 Adding --name-only will also show which file was actually changed. 添加--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 另一个有用的答案: 如何显示带分支名称的git日志

If you happen to be using oh-my-zsh as your terminal then a bunch of git aliases are available. 如果您碰巧使用oh-my-zsh作为终端,那么可以使用一堆git别名。 All of which can be seen at their repo oh-my-zsh/plugins/git . 所有这些都可以在他们的回购哦-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. 接受的答案提供了git log --graph --all --decorate命令,它可以作为oh-my-zsh中的glgga别名使用。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM