Git diff工作不正确 - 对很多更改 [英] Git diff working incorrect - to many changes
问题描述
f1 --- f2 - 短期分支feature1
/ \
h - h - h --- h - h1- -h2- - 长期分支hofix
/ \\\\
/ \\\
m ---- m ------ m- --m ------ m--长期分支主
| |
1e1e1e 2f2f2f
我合并2个提交差异的分支(15个文件已更改totaly)。
然后跑:
$ git show --pretty =format:--name-only 1e1e1e .. 2f2f2f
我从我的项目中收到超过42 000个文件。为什么?
预计:我会用f1,f2,h1,h2提交显示差异
可能是因为Merge branch'origin / 0411-hotfix'commit?
1e1e1e .. 2f2f2f
表示:
- 所有可从
2f2f2f $ c $
- 不包括可从
1e1e1e
- 不包括可从
(请参阅指定范围 gitrevisions
)
如果这些SHA1引用了合并的两个提交,您可以:
1e1e1e
|
x - x - x
\
Z
/
y - y - y
|
2f2f2f
这会给你所有' y
'提交,它可能会直到第一次提交,这意味着你得到所有文件。
然而,既然 git diff
不会进行一系列的提交(而不是 git show
),您可以尝试,如如何 git show
合并提交并结合差异输出:
git diff --name-only 1e1e1e..2f2f2f
或者简单地使用合并SHA1' Z
',如列出git merge commit中的所有修改文件 - 甚至快速转发:
git log -m -1 - 仅限名称--pretty = format:<合并SHA>
f1---f2 - short term branch "feature1"
/ \
h--h--h---h--h1--h2- - long term branch "hofix"
/ \ \ \
/ \ \ \
m----m------m---m------m-- - long term branch "master"
| |
1e1e1e 2f2f2f
I merge branches with 2 commits difference (15 file changed totaly). And ran:
$ git show --pretty="format:" --name-only 1e1e1e..2f2f2f
I receive more than 42 000 file changed from my project. Why?
Expected: i will show diff with f1,f2,h1,h2 commits
P.S. May be because "Merge branch 'origin/0411-hotfix'" commit?
1e1e1e..2f2f2f
means:
- all commits that are reachable from
2f2f2f
- excluding those that are reachable from
1e1e1e
(See "SPECIFYING RANGE" from gitrevisions
)
If those SHA1s reference the two commits merged, you have:
1e1e1e
|
x--x--x
\
Z
/
y--y--y
|
2f2f2f
That would give you all the files from all 'y
' commits, which can potentially go as far as the very first commit, and that means you get all the files.
However, since git diff
doesn't take a range of commits (as opposed to git show
), you can try, as in "How to "git show
" a merge commit with combined diff output":
git diff --name-only 1e1e1e..2f2f2f
Or simply use the merge SHA1 'Z
', as in "List all modified files in git merge commit - even the fast forwarded":
git log -m -1 --name-only --pretty="format:" <Merge SHA>
这篇关于Git diff工作不正确 - 对很多更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!