Search code examples
gitsvngit-merge-conflict

can git conflict create additional files like svn does


I'm asking about svn feature which I want to know whether it exists for git or not:

When svn has conflicts, it creates some additional files which are sometimes useful:

See https://tortoisesvn.net/docs/nightly/TortoiseSVN_en/tsvn-dug-conflicts.html

filename.mine - my original file as it existed at the working directory.

filename.BASE_REVISION - The file which is the BASE revision before you updated your working copy. It is the file checked out before you made your latest edits.

filename.NEW_REVISION - This is the file that Subversion client just received from the server. Actually this is the file we want to merge with.

This is useful, as sometimes, I want to compare the my local changes with base, or the remote changes with base. or simply select one file, and set it as the resolution of the conflict.

Using git, and getting conflicts, I see the file at the working dir is full with the '>>>' '<<<' signs.

Can I get from git similar behavior like svn, having these additional files? I've looked at git documentation, and did not find something appropriate.

Any idea?


Solution

  • Finally I found a simpler way to create these files, though it is not straightforward.

    git mergetool command generates the desired files. If I run the command with non existent merge tool for a given conflicted file, it generates the base file, local file, and remote file similar to what svn generates:

    git mergetool --tool whatever a.txt

    gives output:

    Merging:
    a.txt
    Normal merge conflict for 'a.txt':
       {local}: modified file
       {remote}: modified file
    Unknown merge tool whatever
    

    now ls shows new files named 'a_BASE','a_LOCAL','a_REMOTE' (with process id added to filename) were created:

    $ ls
    a.txt  a_BACKUP_9348.txt  a_BASE_9348.txt  a_LOCAL_9348.txt  a_REMOTE_9348.txt