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。
你怎么能在终端获得树状的提交视图?
#1楼
你怎么能在终端获得树状的提交视图?
git log --graph --oneline --all
是一个好的开始。
你可能会收到一些奇怪的信件。 它们是颜色和结构的ASCII码。 要解决此问题,请将以下内容添加到.bashrc
:
export LESS="-R"
这样你就不需要使用Tig的ASCII过滤器了
git log --graph --pretty=oneline --abbrev-commit | tig // Masi needed this
来自Git-ready的文章基于文本的图包含其他选项:
git log --graph --pretty=oneline --abbrev-commit
关于你提到的文章,我会选择Pod的答案 :ad-hoc hand-made output。
的JakubNarębski提到在评论TIG ,一个基于ncurses的文本模式界面饭桶。 查看他们的发布 。
它在2007年增加了一个--graph
选项 。
#2楼
git log --oneline --decorate --all --graph
包含分支名称的可视树。
使用此选项将其添加为别名
git config --global alias.tree "log --oneline --decorate --all --graph"
你打电话给它
git tree
#3楼
tig
如果需要交互式树,可以使用tig
。 它可以在OSX上通过brew
安装,在Linux中通过apt-get
安装。
brew install tig
tig
这就是你得到的:
#4楼
保持命令简短将使它们更容易记住:
git log --graph --oneline
#5楼
解决方案是在.gitconfig
创建一个Alias并轻松调用它:
[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中。)
#6楼
我建议任何人写下完整的命令
git log --all --decorate --oneline --graph
而不是创建一个别名。
将命令放到头脑中是很好的,因此您可以用心去了解它,即在更换机器时不依赖于别名。