Reputation: 189876
Is there an easy way in Git to determine whether a given file changed between revision hashes A and B?
I know I can do this easily if I can determine the revision hashes A' and B', where A'=predchange(A, path) and B'=predchange(B, path), where predchange(X, path) is the most recent parent of X (or X itself) where the given path was changed. Then I just check whether A' == B'.
Upvotes: 0
Views: 51
Reputation: 3581
git diff <A> <B> -- <path> | wc -l
0 means the file was not changed.
Upvotes: 0
Reputation: 9798
git diff [--stat] A..B -- path/to/file
With --stat
, it simply shows a one-line summary of the changes. Without, it shows the actual diff.
The A..B
syntax is a revision range. It scans as "All commits reachable from B, but not from A". When you pass a revision range to diff, it shows diffs from all commits in the range. A
and B
are "commitish" - either SHA1's identifying commits, refs or tags, HEAD, or any of the previous combined with the special selectors such as ^
.
Upvotes: 3