Git : find all commits that modify a file that are not related to my commit and another one

53 views Asked by At

I want to know if there are any commits elsewhere unrelated to mine that modify files of a given folder, that I might be interested in. I also want to exclude revisions that are ancestors of another known commit.

For one revision, I think it's pretty easy, I can do :

git log --all <rev1>.. <folder>

But how to exclude another revision ?

2

There are 2 answers

6
Mohamed amine ben hassen On BEST ANSWER

just add --not and your branch name to exclude it from being shown :

git log --all < rev1>.. --not <known_commit> -- < folder >

4
knittl On

It's probably clearer to not use the range syntax at all, but to exclude the commits explicitly:

git log --all ^rev1 ^rev2 -- <folder>

^rev excludes all commits reachable from rev1 (including rev1). In other words rev1..rev2 as dotted range notation is equivalent to ^rev1 rev2.