简体   繁体   中英

Why does “git log --name-only” show one file change, but “git diff” shows more?

When I run

git log --name-only

it shows sha1 and sha2 as consecutive commits and only one file was changes in sha2.

However, when I run

git diff sha1 sha2

it shows differences in a lot of files. Why is this? sha1 and sha2 are consecutive commit ids that I got from git log --name-only. sha1 is the earlier commit.

I thought that git diff would only show differences in files that are listed by git log --name-only .

The sha1 and sha2 are consecutive commits in the same branch.

sha1 was a cherry pick from B1 and sha2 was cherry picked from B2 .

I found that a file that was not listed in git log --name-only was modified and basically my changes in B1 were overwritten by B1 commit, even though it isn't listed as having been modified.

Is there an issue with the cherry-picking here where changes are picked up unknowingly?

您需要将git-log调用更改为

git log --name-only sha1..sha2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM