有没有办法在Git中只显示分支结构?有很多工具可以用图形方式显示提交内容,但在我的情况下,列表太长以至于看不到结构。我猜git-log可能是答案,但我找不到任何只显示分支提交的开关。这与“--graph --branches --oneline --all”一起可以做到这一点。显示Git分支结构
编辑:我正在寻找一种方法来做到这一点在Ubuntu。
有没有办法在Git中只显示分支结构?有很多工具可以用图形方式显示提交内容,但在我的情况下,列表太长以至于看不到结构。我猜git-log可能是答案,但我找不到任何只显示分支提交的开关。这与“--graph --branches --oneline --all”一起可以做到这一点。显示Git分支结构
编辑:我正在寻找一种方法来做到这一点在Ubuntu。
我不知道你的意思是什么“分支结构”。
git log
可以帮助想像在提交所做的分支机构(见本blog post):
[alias]
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
但是如果你只想要不同的HEAD分支,你可以尝试something along the lines of:
heads = !"git log origin/master.. --format='%Cred%h%Creset;%C(yellow)%an%Creset;%H;%Cblue%f%Creset' | git name-rev --stdin --always --name-only | column -t -s';'"
(使用column command
,这里仅用于自上次提交origin/master
以来的提交)
注意:Jakub Narębski推荐添加选项--simplify-by-decoration
,请参阅his answer。
这非常接近(后一种解决方案),我只需将日期和 - 分支添加到命令。否则它只显示当前分支。尽管它仍然没有忽略不是头的提交。我所说的“分支结构”是一种从每个分支创建的分支中查看的方式,但通过此命令,我可以滚动列表(其中有大约350个提交)来查看发生了什么。 – Makis 2010-09-08 12:34:23
@Makis:如果你有最后的命令,你可以把它作为答案发布:我感兴趣(并将它投票)。然后,如果你愿意,你甚至可以接受你自己的答案作为官方答案。 – VonC 2010-09-08 13:26:51
我仍在研究它,明天我会回到办公室去尝试理解结构。回购是用svn2git创建的,我并不是100%确定svn回购是由该书提供的。 – Makis 2010-09-08 16:47:42
要获得特定分支如何涉及你的资料库和遥控器等分支机构,则可以使用git wtf
它是由威廉·摩根在脚本中添加更多的信息:http://git-wt-commit.rubyforge.org/
它产生像摘要信息:
$ git wtf
Local branch: master
[x] in sync with remote
Remote branch: origin/master ([email protected]:willgit/mainline.git)
[x] in sync with local
Feature branches:
{ } origin/experimental is NOT merged in (1 commit ahead)
- some tweaks i'm playing around with [80e5da1]
{ } origin/dont-assume-origin is NOT merged in (1 commit ahead)
- guess primary remote repo from git config instead of assuming "origin" [23c96f1]
(取自上述URL的示例)。
,基本解决方案是:
git log --graph --all
如果你想获得更多的花哨:
git log --graph --all --pretty=format:"%Cblue%h%Creset [%Cgreen%ar%Creset] %s%C(yellow)%d%Creset"
也许你想要的是--simplify-by-decoration
选项,请参阅git log文档:
- - 简化装修
选择某个分支或标记引用的提交。
因此,这将是
git log --graph --simplify-by-decoration --all
或以下VonC answer
git log --graph --simplify-by-decoration \
--pretty=format:'%Cred%h%Creset-%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' \
--abbrev-commit --date=relative
也许我失去了一些东西,但似乎没有人提到gitk --all
呢。
它也显示所有个人提交。 – 2012-02-22 14:54:46
我刚刚尝试过'gitk --all - 简化了装饰,并且工作得很好。 (这是用git 1.7.9.5提供的gitk) – Rhubbarb 2013-10-15 17:41:28
可能重复的[漂亮的git分支图](http://stackoverflow.com/questions/1057564/pretty-git-branch-graphs) – trblnc 2017-01-30 11:48:57