Reputation: 2480
When executing a git fetch
or get pull
there might be a conflict. Is there a way to get copies of all conflicting files? For example file foo.dat
is in conflict, then I would like to have copies foo.dat.ours
and foo.dat.theirs
. I think SVN has a similar behaviour.
git diff --name-only --diff-filter=U
.ours
postfix (xargs cp
)Upvotes: 5
Views: 81
Reputation: 39354
From the Git SCM book, under "Manual File Re-merging" we see:
Git stores all of these versions in the index under “stages” which each have numbers associated with them. Stage 1 is the common ancestor, stage 2 is your version and stage 3 is from the MERGE_HEAD, the version you’re merging in (“theirs”).
From that, here's an approximate bash script approach:
for file in $(git diff --name-only --diff-filter=U); do
git show ":1:${file}" > "${file}".common
git show ":2:${file}" > "${file}".ours
git show ":3:${file}" > "${file}".theirs
done
Upvotes: 3