How to find intersections between two git commits?

Namely, I'm interested in finding files that have been changed in both commits (or in two differences, if it's easier). Sorry if this is easy, but I'm still pretty new to git.

+4
source share
2 answers

Update

After entering from @PaulHicks ( git diffinstead of git diff-tree... thanks Paul) and getting around the error described here , i.e. | sorthere is my updated answer:

comm -12 <(git diff --no-commit-id --name-only -r 3fe29472016343 | sort) <(git diff --no-commit-id --name-only -r 9fd796b1998bb7d5 | sort)

Old answer I do not believe that there is a team out of the box to do what you want to achieve. However, if you are on * nix platforms, you can try the following:

comm -12  <(git diff-tree --no-commit-id --name-only -r COMMIT1SHA1key) <(git diff-tree --no-commit-id --name-only -r COMMIT2SHA1key)

, :(..hence ( )

git diff-tree , .

, comm -12 ls.

-

+2

, , git diff --name-only sha1^ sha1. , script, SHA-1 :

git diff --name-only $1^ $1 | sort > file1
git diff --name-only $2^ $2 | sort > file2
comm -12 file1 file2
rm file1 file2

, bash linux/unix, @Vikram, :

comm -12 < (git diff --name-only $1^ $1) < (git diff --name-only $2^ $2)
+1

Source: https://habr.com/ru/post/1528836/


All Articles