无法在终端中显示 Git 树

发布于 2024-07-26 00:10:56 字数 476 浏览 2 评论 0 原文

Killswitchcollective.com 的旧文章,2009 年 6 月 30 日,有以下输入和输出

git co master
git merge [your_branch]
git push

upstream    A-B-C-D-E            A-B-C-D-E-F-G
                 \        ---->               \
your branch       C-D-E                        G

我感兴趣的是你如何获得终端中提交的树状视图,无需在 OS/X 中使用 Gitk 或 Gitx。

如何在终端中获取提交的树状视图?

Killswitchcollective.com's old article, 30 June 2009, has the following inputs and outputs

git co master
git merge [your_branch]
git push

upstream    A-B-C-D-E            A-B-C-D-E-F-G
                 \        ---->               \
your branch       C-D-E                        G

I am interested how you get the tree like-view of commits in your terminal without using Gitk or Gitx in OS/X.

How can you get the tree-like view of commits in terminal?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

分開簡單 2024-08-02 00:10:56

如何在终端中获得提交的树状视图?

git log --graph --oneline --all

是一个好的开始。

您可能会收到一些奇怪的信件。 它们是颜色和结构的 ASCII 代码。 要解决此问题,请将以下内容添加到您的 .bashrc 中:

export LESS="-R"

这样您就不需要通过

git log --graph --pretty=oneline --abbrev-commit | tig   // Masi needed this 

文章 来自 Git-ready 的基于文本的图表 包含其他选项:

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

git log graph

关于你提到的文章,我会选择 Pod 的答案:临时手工输出。


Jakub Narębski 在评论中提及tig,一个基于 ncurses 的 git 文本模式界面。 请参阅他们的版本
它早在 2007 年就添加了--graph 选项

How can you get the tree-like view of commits in terminal?

git log --graph --oneline --all

is a good start.

You may get some strange letters. They are ASCII codes for colors and structure. To solve this problem add the following to your .bashrc:

export LESS="-R"

such that you do not need use Tig's ASCII filter by

git log --graph --pretty=oneline --abbrev-commit | tig   // Masi needed this 

The article text-based graph from Git-ready contains other options:

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

git log graph

Regarding the article you mention, I would go with Pod's answer: ad-hoc hand-made output.


Jakub Narębski mentions in the comments tig, a ncurses-based text-mode interface for git. See their releases.
It added a --graph option back in 2007.

以为你会在 2024-08-02 00:10:56

解决方案是在 .gitconfig 中创建一个别名并轻松调用它:

[alias]
    tree = log --graph --decorate --pretty=oneline --abbrev-commit

下次调用它时,您将使用:

git tree

将其放入 ~/.gitconfig 中,而无需编辑它,你可以这样做:(

git config --global alias.tree "log --graph --decorate --pretty=oneline --abbrev-commit"  

如果你不使用 --global ,它会将其放入当前存储库的 .git/config 中。)

A solution is to create an Alias in your .gitconfig and call it easily:

[alias]
    tree = log --graph --decorate --pretty=oneline --abbrev-commit

And when you call it next time, you'll use:

git tree

To put it in your ~/.gitconfig without having to edit it, you can do:

git config --global alias.tree "log --graph --decorate --pretty=oneline --abbrev-commit"  

(If you don't use the --global it will put it in the .git/config of your current repo.)

方觉久 2024-08-02 00:10:56
git log --oneline --decorate --all --graph

包含分支名称的可视化树。

使用它将其添加为别名

git config --global alias.tree "log --oneline --decorate --all --graph"

您可以使用

git tree

Git Tree调用它

git log --oneline --decorate --all --graph

A visual tree with branch names included.

Use this to add it as an alias

git config --global alias.tree "log --oneline --decorate --all --graph"

You call it with

git tree

Git Tree

三生路 2024-08-02 00:10:56

tig

如果你想要一个交互式树,你可以使用tig。 它可以通过 OSX 上的 brew 和 Linux 上的 apt-get 安装。

brew install tig
tig

这就是您得到的结果:

在此处输入图像描述

tig

If you want a interactive tree, you can use tig. It can be installed by brew on OSX and apt-get in Linux.

brew install tig
tig

This is what you get:

enter image description here

疯狂的代价 2024-08-02 00:10:56

我建议任何人写下完整的命令

git log --all --decorate --oneline --graph

而不是创建别名。

将命令记入您的脑海中是很好的,这样您就可以记住它
即当您更换机器时不依赖别名。

I would suggest anyone to write down the full command

git log --all --decorate --oneline --graph

rather than create an alias.

It's good to get the commands into your head, so you know it by heart
i.e. do not depend on aliases when you change machines.

沧桑㈠ 2024-08-02 00:10:56

保持命令简短将使它们更容易记住:

git log --graph --oneline

Keeping your commands short will make them easier to remember:

git log --graph --oneline
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文