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


当前回答

除了“Slipp D.Thompson”的答案外,我建议您添加此别名以具有相同的装饰,但通过提交将其添加到单行中:

git config --global alias.tre "log --graph --decorate --pretty=oneline --abbrev-commit --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)'"

其他回答

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生成它。

看着这段对话,我试着用我最喜欢的git可乐和git dag。

正在运行视图->DAG。。。从git-cola中删除并替换Log:master-with-都显示了一个包含所有分支的漂亮图形。

对于文本输出,您可以尝试:

git log --graph --abbrev-commit --decorate --date=relative --all

Or:

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

或者:这里有一个Graphviz别名,用于绘制DAG图。

我个人使用gitx、gitk-all和gitnub。

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

除了“Slipp D.Thompson”的答案外,我建议您添加此别名以具有相同的装饰,但通过提交将其添加到单行中:

git config --global alias.tre "log --graph --decorate --pretty=oneline --abbrev-commit --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)'"