显示Git分支结构

Mak*_*kis 34 git branch git-branch

有没有办法只在Git中显示分支结构?有许多的,显示的图形提交工具,但对我来说名单很长,所以这是不可能看到的结构.我猜git-log可能是答案,但我找不到任何只显示分支提交的开关.这与"--graph --branches --oneline --all"一起可以解决问题.

编辑:我正在寻找一种方法在Ubuntu中做到这一点.

Von*_*onC 31

我不确定你的"分支结构"是什么意思.
git log可以帮助可视化通过提交创建的分支(请参阅此博客文章):

[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"
Run Code Online (Sandbox Code Playgroud)

替代文字

但是如果你只想要不同的HEAD分支,你可以尝试以下方面:

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';'"
Run Code Online (Sandbox Code Playgroud)

(使用column command,此处仅用于自上次origin/master提交以来的提交)

注意:JakubNarębski建议添加该选项 --simplify-by-decoration,请参阅他的回答.


Jak*_*ski 27

也许您想要的是--simplify-by-decoration选项,请参阅git log文档:

--simplify逐装饰

     选择某些分支或标记引用的提交.

所以它会

git log --graph --simplify-by-decoration --all
Run Code Online (Sandbox Code Playgroud)

或者按照VonC的回答

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
Run Code Online (Sandbox Code Playgroud)


Ben*_*jol 9

也许我错过了什么,但似乎没有人提到过gitk --all.

  • 我刚试过`gitk --all --simplify-by-decoration`,效果很好.(那是git 1.7.9.5提供的gitk) (3认同)

cmc*_*nty 6

基本解决方案是:

git log --graph --all
Run Code Online (Sandbox Code Playgroud)

如果你想得到更多的幻想:

git log --graph --all --pretty=format:"%Cblue%h%Creset [%Cgreen%ar%Creset] %s%C(yellow)%d%Creset"
Run Code Online (Sandbox Code Playgroud)