你试过git rev-list --first-parent newrev
吗?它似乎列出了分支之间的所有转速newrev
和分支来自的参考。例如,在这个 repo 中:
$ git log --all --graph --decorate
* commit 03f6357bdcacfc8c8253ccb140f25010810c4433 (HEAD, origin/new_branch, new_branch)
| Fifth
* commit 291d88908fefa94eab0c9483ad6b8ab5ebca21f6
| Third
* commit 3ff20b8998d037cd9c9bb1ff53b1887837d9ed8e
| Second
| * commit e9c2e99de892499d2b6037c8c0913a52dbade4c0 (origin/master, master)
|/ Fourth
* commit 9574226673ffe2d04ae4e36b4d7976399320e29f
First
rev-list
给出以下内容:
$ git rev-list --first-parent 03f6357bdcacfc8c8253ccb140f25010810c4433
03f6357bdcacfc8c8253ccb140f25010810c4433
291d88908fefa94eab0c9483ad6b8ab5ebca21f6
3ff20b8998d037cd9c9bb1ff53b1887837d9ed8e
9574226673ffe2d04ae4e36b4d7976399320e29f
您可以将其限制为仅使用基本参考tail -1
(我还没有找到一个 CLI 选项来更优雅地做到这一点):
$ git rev-list --first-parent 03f6357bdcacfc8c8253ccb140f25010810c4433 | tail -1
9574226673ffe2d04ae4e36b4d7976399320e29f
从那里,您可以使用原始git diff
命令:
$ origrev=`git rev-list --first-parent 03f6357bdcacfc8c8253ccb140f25010810c4433 | tail -1`
$ git diff --name-status --diff-filter=AM $origrev 03f6357bdcacfc8c8253ccb140f25010810c4433
A bar