git log -1 --merges --ancestry-path <commit-A>..HEAD -- path/to/file
Use this to identify the first merge commit on the mainline (first-parent path) from <commit-A>
to HEAD
that touched a specific file. Especially useful when a line disappears due to merge conflict resolution and isn't visible with -S
or -G
.
git log
β View commit history-1
β Return only the most recent matching commit--merges
β Filter to merge commits only--ancestry-path <A>..HEAD
β Follow only the mainline ancestry (parent chain) from A to HEAD-- path/to/file
β Limit results to commits that changed the specific file