如何使用git log --graph显示标签名称和分支名称 [英] How to display the tag name and branch name using git log --graph
问题描述
我正在使用gitk - 全部查看git日志。 gitk不会为每个提交显示sha哈希值。你需要手动点击提交来查看sha哈希。我希望在单个视图中看到sha散列和分支名称。
如何使用git log命令显示标签名称和分支名称
git log
(所以,不是gitk),您可以使用装饰选项(%d
)以漂亮的格式显示分支名称(但仅限于所有分支的头部提交): alias.lgb = log --graph --pretty = format:'%Cred%h%Creset - %C(yellow)%d%Creset%s% Cgreen(%cr)%C(粗体蓝色)<%an>%Creset%n'--abbrev-commit --date = relative --branches
(你必须声明别名:
git config - 全球alias.lgblog --graph --pretty =格式:'%Cred%h%Creset - %C(黄色)%d%Creset%s%Cgreen(%cr)%C(粗体蓝色)<%an> ;%Creset%n'--abbrev-commit --date = relative --branches
然后你可以使用' git lgb
'。注意:哟你可以用不同的别名命名它。
)
会给:
* e33afe7 - (HEAD,master)修复cygwin上的zlib make install问题(8秒前)< VonC>
|
* f825f36 - 为gcc的cygwin编译添加CPPFLAG选项(26小时前)< VonC>
|
* 9341979 - (origin / master,origin / HEAD)在cygwin中(2天前)更新用于编译gcc的错误消息< VonC>
|
* 42d81af - 在$ H / usr / local / bin中复制dll,而不是在cygwin中编译时链接(3天前)< VonC>
更新Git 2.2(2014年11月) a href =https://github.com/git/git/commit/9271095cc5571e306d709ebf8eb7f0a388254d9d =noreferrer> commit 9271095 from Harry Jeffery( eXeC64
):
漂亮
:添加%D
格式说明符
格式说明符'
%D
',它的行为与'%d
'相同,除了它不包含由<%d $提供的'
(
'前缀或')
'后缀c $ c>'。
I am using gitk --all to view the git log. gitk does not display the sha hash for each commit. you need to manually click on the commit to view the sha hash. I want to see the sha hash and the branch name in a single view.
How to display the tag-names and branch names using the git log command.
With git log
(so, not gitk), you can use the decorate option (%d
) in a pretty format, for displaying the branch name (but only for commits which are the HEAD of said branches):
alias.lgb=log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset%n' --abbrev-commit --date=relative --branches
(you have to declare that alias with:
git config --global alias.lgb "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset%n' --abbrev-commit --date=relative --branches"
Then you can use it with 'git lgb
'. Note: you can name it with a different alias.
)
Will give:
* e33afe7 - (HEAD, master) fix zlib make install issue on cygwin (8 seconds ago) <VonC>
|
* f825f36 - add CPPFLAG option for cygwin compilation of gcc (26 hours ago) <VonC>
|
* 9341979 - (origin/master, origin/HEAD) update error messages for compiling gcc within cygwin (2 days ago) <VonC>
|
* 42d81af - copy dll in $H/usr/local/bin instead of linking when compiling in cygwin (3 days ago) <VonC>
Update Git 2.2 (November 2014): see commit 9271095 from Harry Jeffery (eXeC64
):
pretty
: add %D
format specifier
Add a new format specifier, '
%D
' that is identical in behaviour to '%d
', except that it does not include the '(
' prefix or ')
' suffix provided by '%d
'.
这篇关于如何使用git log --graph显示标签名称和分支名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!