我见过一些书籍和文章中有一些非常漂亮的Git分支和提交的图表。如何制作Git历史的高质量可打印图像?


当前回答

我建议tighttps://github.com/jonas/tig,一个更好的Git命令行工具。

您可以使用Homebrew在macOS上安装tig:

$ brew install tig
$ tig

其他回答

有一个时髦的Git提交图作为Raphael web图形库的演示之一。

这个演示是静态的,但应该很容易获取代码并将静态数据交换为一组实时数据——我认为这只是JSON格式的Git提交数据。

演示在这里:http://dmitrybaranovskiy.github.io/raphael/github/impact.html

稍微调整一下Slipp的精彩回答,你可以使用他的别名记录一个分支:

[alias]
lgBranch1 = log --graph --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(bold white)— %an%C(reset)%C(bold yellow)%d%C(reset)' --abbrev-commit --date=relative
lgBranch2 = log --graph --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n''          %C(white)%s%C(reset) %C(bold white)— %an%C(reset)' --abbrev-commit
lg = !"git lg1"

你现在可以做的一切

git lgBranch1 <branch name>

甚至

git lgBranch1 --all

这里的许多答案都很好,但对于那些只想得到一个简单的一行到位的答案而不必设置别名或其他任何东西的人来说,这里是:

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

不是每个人都会一直做git日志,但当你需要它时,请记住:

“A Dog”=git log--all--decorate--oneline--graph

如果您输入

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

在命令提示符下,可以使用

git adog

即使您关闭并重新打开它,也可以从该提示中删除。

我不知道有什么直接的工具,但也许你可以破解一个脚本,将数据导出为点格式,并用Graphviz渲染。

Gitgraph.js允许在没有存储库的情况下绘制漂亮的Git分支。只需编写一个JavaScript代码来配置分支和提交并在浏览器中呈现。交互式文档可用。

var gitGraph = new GitGraph({
   template: "blackarrow",
   mode: "compact",
   orientation: "horizontal",
   reverseArrow: true
});

var master = gitGraph.branch("master").commit().commit();
var develop = gitGraph.branch("develop").commit();
master.commit();
develop.commit().commit();
develop.merge(master);

或使用地铁模板:

或者使用提交消息、作者和标签:

用JSFiddle测试它。

通过@bsara使用GitGraper生成它。