Git: How to get copies of conflicting files?

When executing git fetchor there get pullmay be a conflict. Is there a way to get copies of all conflicting files? For example, the file foo.datis in conflict, then I would like to have copies of foo.dat.oursand foo.dat.theirs. I think SVN has similar behavior.

  • Get conflicting file names git diff --name-only --diff-filter=U
  • Submit a copy with .ourspostfix ( xargs cp)
  • Get a copy of them?
+4
source share
1 answer

From Git's SCM book in the section "Manually re-merging files" we see:

Git "", , . 1 - , - , 3 - MERGE_HEAD, , ( "" ).

bash script:

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
+3

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


All Articles