How to make git to save different versions of a conflicted file into the workspace

286 views Asked by At

In SVN if there is a conflict, the different versions of the conflicted file are saved to the workspace with postfixes. Can I have this in Git as well? I should now hold some training about TortoiseGit, and if a binary conflict occurs, I don't see any simple option to have the different versions of the file in the workspace. I know that I can checkout the file from a specific hash with a different name, but I want it automatically.

So what I want in my workspace automatically saved in case of a conflict:

  • myconflictedfile.doc
  • myconflictedfile.doc.base
  • myconflictedfile.doc.theirs
  • myconflictedfile.doc.mine

Is it possible?

1

There are 1 answers

2
VonC On

In case of a merge conflict, git already save those different version for you:
From git help merge:

Look at the originals:

  • git show :1:filename shows the common ancestor,
  • git show :2:filename shows the HEAD version, and
  • git show :3:filename shows the MERGE_HEAD version.

You can also quickly resolve a conflict merge by choosing 'mine' or 'their' version.

git checkout --ours   yourfile # Your version
git checkout --theirs yourfile # Repository version