Search code examples
gitmergemergetool

Is there a way to make Git mark a file as conflicted?


It's possible to commit files that contains conflict data. Is there a way to mark these files as conflicted again, so that running git mergetool will generate the necessary files and run the merge tool?


Solution

  • If the index is already in a conflict state, simply check out the file with the --conflict=merge flag:

    git checkout --conflict=merge file
    

    If the index is clean because the unresolved file has been [erroneously] added, just reset it before checking it out:

    git reset file
    git checkout --conflict=merge file
    

    This will allow you to resume conflict resolution normally (e.g., git mergetool).

    NOTE: Promoting a comment to @jakub-narębski's answer into its own answer by request from @fourpastmidnight. :)