gpt4 book ai didi

git - 像时尚的树中的 git 分支的输出

转载 作者:IT王子 更新时间:2023-10-29 01:21:20 25 4
gpt4 key购买 nike

现在,当我输入“git branch”

它以任意顺序列出我的分支。

如果“git branch”在像 fasion 这样的树中列出我的输出,我更喜欢这样:

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

在这里,foo 和 bar 是从 master 分支出来的; foo1 & foo2 是从 foo 分支出来的; bar4 是从 bar 分支出来的。

这很容易实现吗?

[仅限命令行实用程序。这需要适合我的 zsh/vim 工作流程。]

最佳答案

answer below使用 git log :

我在 2009 年用“Unable to show a Git tree in terminal”提到了类似的方法:

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

但我一直在使用的完整版本在“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

原始答案(2010 年)

git show-branch --list接近您要查找的内容(使用拓扑顺序)

--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).

但是工具git wtf可以help too .示例:

$ 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 - 像时尚的树中的 git 分支的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2421011/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com