在树中输出git分支就像时尚 [英] Output of git branch in tree like fashion

查看:153
本文介绍了在树中输出git分支就像时尚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



现在,当我输入git branch时,它会以任意顺序列出我的分支。

p>我更喜欢的是如果git分支将我的输出列在fasion这样的树中,像下面这样的事情:

  master 
| - foo
| - foo1
| - foo2
| - bar
| - bar4

在这里,foo&酒吧从主人分支; foo1& foo2从foo分支; bar4从bar中分支出来。



这是否容易实现?

[仅限命令行实用程序。这需要适合我的zsh / vim工作流程。] 下面的答案使用 git log



我在2009年提到了一个类似的方法,用无法在终端显示Git树

  git log --graph  - -pretty = oneline --abbrev-commit 

但是我一直使用的完整版本是 a href =https://stackoverflow.com/a/7023272/6309>如何使用git log --graph 显示标签名称和分支名称(2011):

  git config --global alias.lgblog --graph --pretty = format:'%Cred%h%Creset  - %C(yellow)% d%Creset%s%Cgreen(%cr)%C(粗体蓝色)<%an>%Creset%n'--abbrev-commit --date = relative --branches

git lgb






原始a nswer(2010)

git show-branch --list 接近您要查找的内容(使用topo命令)

   - 地磅订单




默认情况下,分支及其提交按反向时间顺序显示。

此选项使它们以拓扑顺序显示(即,后代提交显示在它们之前父母)。


但是 git wtf 可以帮忙。例子:

$ $ p $ $ g $ wtf
本地分支master
不与远程同步推)
- 添加搜索前钩子,以获取自定义搜索查询的快捷方式。 [4430d1b](edwardzyang @ ...; 7天前)
远程分支:origin / master(git@gitorious.org:sup / mainline.git)
[x]与本地$ b同步
$ b特性分支:
{} origin / release-0.8.1不合并到(1 commit ahead)
- bump到0.8.1 [dab43fb](wmorgan-sup @。 ..; 2天前)
[] label-before-subj不合并(1提前提交)
- 在线索引视图中的主题前放置标签[790b64d](marka @ ...;
{x} origin / enclosed-message-display-tweaks合并到
(x)合并的实验(仅在本地)

注意:工作目录包含修改文件




git-wtf


  • 如果分支是跟踪分支,你的分支如何与远程repo相关。

  • 如果您的分支是功能分支,您的分支如何与非功能(版本)分支相关。

  • 如果您的分支与功能分支相关,



Right now, when I type "git branch"

it lists my branches in an arbitrary order.

What I would prefer would be if "git branch" listed my output in a tree like fasion, somethign like:

master
|-- foo
  |-- foo1
  |-- foo2
|-- bar
  |-- bar4

Where here, foo & bar were branched from master; foo1 & foo2 were branched from foo; bar4 was branched from bar.

Is this easy to accomplish?

[Command line utilities only. This needs to fit into my zsh/vim workflow.]

解决方案

The answer below uses git log:

I mentioned a similar approach in 2009 with "Unable to show a Git tree in terminal":

git log --graph --pretty=oneline --abbrev-commit

But the full one I have been using is in "How to display the tag name and branch name using 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


Original answer (2010)

git show-branch --list comes close of what you are looking for (with the topo order)

--topo-order

By default, the branches and their commits are shown in reverse chronological order.
This option makes them appear in topological order (i.e., descendant commits are shown before their parents).

But the tool git wtf can help too. Example:

$ 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

git-wtf shows you:

  • How your branch relates to the remote repo, if it's a tracking branch.
  • How your branch relates to non-feature ("version") branches, if it's a feature branch.
  • How your branch relates to the feature branches, if it's a version branch

这篇关于在树中输出git分支就像时尚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆