git log --oneline --graph 的使用

27 阅读1分钟

可视化差异对比

1. Git Merge 的图形展示

# merge 会保留分支历史,形成分叉图形
git log --oneline --graph

# 输出类似:
*   a1b2c3d (HEAD -> main) Merge branch 'feature'
|\  
| * e4f5g6h (feature) Feature commit
* | h7i8j9k Main commit  
|/  
* m9n0o1p Base commit

2. Git Rebase 的图形展示

# rebase 会创建线性历史,没有分叉
git log --oneline --graph

# 输出类似:
* x1y2z3a (HEAD -> main, feature) Feature commit
* h7i8j9k Main commit
* m9n0o1p Base commit