现在,当我键入"git branch"
它以任意顺序列出我的分支.
我更喜欢的是,如果"git branch"将我的输出列在像fasion这样的树中,有些像:
master
|-- foo
|-- foo1
|-- foo2
|-- bar
|-- bar4
Run Code Online (Sandbox Code Playgroud)
在这里,foo&bar是从主人那里分出来的; foo1和foo2从foo分支出来; bar4从bar分支.
这很容易实现吗?
[仅限命令行实用程序.这需要适合我的zsh/vim工作流程.]
Von*_*onC 172
我在2009年提到了类似的方法," 无法在终端中显示Git树 ":
git log --graph --pretty=oneline --abbrev-commit
Run Code Online (Sandbox Code Playgroud)
但我使用的完整版本是" 如何使用git log --graph显示标记名称和分支名称 "(2011):
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"
git lgb
Run Code Online (Sandbox Code Playgroud)
原始答案(2010)
git show-branch --list 接近您正在寻找的东西(使用拓扑订单)
--topo-order
Run Code Online (Sandbox Code Playgroud)
默认情况下,分支及其提交以反向时间顺序显示.
此选项使它们以拓扑顺序显示(即,后代提交显示在其父项之前).
$ git wtf
Local branch: master
[ ] NOT in sync with remote (needs push)
- Add before-search hook, for shortcuts for custom search queries. [4430d1b] (edwardzyang@...; 7 days ago)
Remote branch: origin/master (git@gitorious.org:sup/mainline.git)
[x] in sync with local
Feature branches:
{ } origin/release-0.8.1 is NOT merged in (1 commit ahead)
- bump to 0.8.1 [dab43fb] (wmorgan-sup@...; 2 days ago)
[ ] labels-before-subj is NOT merged in (1 commit ahead)
- put labels before subject in thread index view [790b64d] (marka@...; 4 weeks ago)
{x} origin/enclosed-message-display-tweaks merged in
(x) experiment merged in (only locally)
NOTE: working directory contains modified files
Run Code Online (Sandbox Code Playgroud)
git-wtf告诉你:
- 如果它是跟踪分支,您的分支如何与远程仓库相关.
- 如果它是一个特征分支,那么您的分支如何与非特征("版本")分支相关联.
- 如果它是版本分支,您的分支如何与功能分支相关联
noc*_*ash 134
这不是你要求的,但是
git log --graph --simplify-by-decoration --pretty=format:'%d' --all
Run Code Online (Sandbox Code Playgroud)
做得很好.它还显示标签和远程分支.这可能并不适合每个人,但我发现它很有用.--simplifiy-by-decoration这是限制所示参考的重要技巧.
我使用类似的命令来查看我的日志.我已经能够gitk用它完全取代我的用法:
git log --graph --oneline --decorate --all
Run Code Online (Sandbox Code Playgroud)
我通过在〜/ .gitconfig文件中包含这些别名来使用它:
[alias]
l = log --graph --oneline --decorate
ll = log --graph --oneline --decorate --branches --tags
lll = log --graph --oneline --decorate --all
Run Code Online (Sandbox Code Playgroud)
编辑:更新建议的日志命令/别名以使用更简单的选项标志.
Gab*_*les 12
使用git show-tree:
在 Ubuntu 上测试:
# Install it
sudo apt install git-extras
# Run it:
git-show-tree
# OR (same thing)
git show-tree
Run Code Online (Sandbox Code Playgroud)
这会产生类似于此处 2 个最受好评的答案的效果。
来源:http : //manpages.ubuntu.com/manpages/bionic/man1/git-show-tree.1.html
例子:
man git show-tree 显示以下示例:
例子
将所有分支的提交历史日志输出为树视图:
Run Code Online (Sandbox Code Playgroud)* 4b57684 (HEAD, develop) Merge branch upstream master. |\ | * 515e94a Merge pull request #128 from nickl-/git-extras-html-hyperlinks | |\ | | * 815db8b (nickl/git-extras-html-hyperlinks, git-extras-html-hyperlinks) help ronn make hyperlinks. | * | 7398d10 (nickl/develop) Fix #127 git-ignore won´t add duplicates. | |/ | | * ab72c1e (refs/stash) WIP on develop: 5e943f5 Fix #127 git-ignore won´t add duplicates. | |/ |/| * | 730ca89 (bolshakov) Rebase bolshakov with master |/ * 60f8371 (origin/master, origin/HEAD, master) Merge pull request #126 from agrimaldi/fix-changelog-last-tag * 9627780 (tag: 1.7.0) Release 1.7.0 * 2e53ff6 (tag: 1.6.0) Release 1.6.0 * bbd32d8 (tag: 1.5.1) Release 1.5.1 | * 6b6b758 (nickl/gh-pages, gh-pages) add example git-extras to gh-pages | * 19cfd11 (origin/gh-pages) Index page | | * 881a70e (tag: 1.5.0) Release 1.5.0 | |/ |/| * | 4db5ee0 (tag: 1.4.0) Release 1.4.0 * | 9b0bc89 (tag: 1.3.0) Release 1.3.0 * | be49961 (tag: 1.2.0) Release 1.2.0 * | c1d2dfc (tag: 1.1.0) Release 1.1.0 * | 4a56adb (tag: 1.0.0) Release 1.0.0 * | 948308b (tag: 0.9.0) Release 0.9.0 * | 40b131d (tag: 0.8.1) Release 0.8.1 * | 391431d (tag: 0.8.0) Release 0.8.0
这是ardupilot repogit show-tree上的示例输出:
此外,如果您安装了Arcanist(更正:安装了Uber 的 Arcanist 分支——请参阅我的答案底部以获取安装说明),会arc flow显示一个漂亮的上游依赖关系树(即:之前通过arc flow new_branch或手动通过 设置git branch --set-upstream-to=upstream_branch)。示例输出arc flow:
Run Code Online (Sandbox Code Playgroud)master ???graft-D999 ???new_feature_1 ???new_feature_2
我真的觉得这个arc flow视图很漂亮而且很有用,所以我有这个(非活动的,尚未运行的)git tree开源项目,我计划在其中复制它的行为:https : //github.com/ElectricRCAircraftGuy/git-tree。
# Show the currently-checked-out branch
git lg
# OR: show branch_name
git lg branch_name
Run Code Online (Sandbox Code Playgroud)
您也可以添加-p或--patch显示更改的行:
git lg -p
# OR
git lg --patch
Run Code Online (Sandbox Code Playgroud)
要安装的git lg别名(来源:https://coderwall.com/p/euwpig/a-better-git-log):
git config --global alias.lg "log --color --graph \
--pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) \
%C(bold blue)<%an>%Creset' --abbrev-commit"
Run Code Online (Sandbox Code Playgroud)
示例输出显示sshfsrepo上的分叉和合并以及内容:
git branch部分!”小智 11
以下示例还显示了提交父项:
git log --graph --all \
--format='%C(cyan dim) %p %Cred %h %C(white dim) %s %Cgreen(%cr)%C(cyan dim) <%an>%C(bold yellow)%d%Creset'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
109053 次 |
| 最近记录: |