Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6194995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:23:29+00:00 2026-05-24T03:23:29+00:00

When Git detects a conflict during merge, the default behaviour is to fill the

  • 0

When Git detects a conflict during merge, the default behaviour is to fill the file with <<< >>> === markers.

This is OK most of the time, but sometimes I’d like to resolve conflicts differently and I’d just like Git to create distinct files:

  • original version,
  • changed version A,
  • changed version B.

How to achieve that?


If there’s no simple command to create those files in one go (which is somewhat surprising), maybe there is a way to extend Git so that it would do it? A custom mergetool or something? Just an idea.


Solution:

I’ve settled for a variant of @Karl Bielefeldt’s answer:

savefiles.sh

#!bash
BASE=$1
LOCAL=$2
REMOTE=$3
MERGED=$4

cp "$BASE" "$MERGED.git_BASE"
cp "$LOCAL" "$MERGED.git_LOCAL"
cp "$REMOTE" "$MERGED.git_REMOTE"

# never mark the conflict as merged
exit 1 

config

mergetool.savefiles.cmd=/path/to/savefiles.sh $BASE $LOCAL $REMOTE $MERGED
mergetool.savefiles.trustexitcode=true
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:23:31+00:00Added an answer on May 24, 2026 at 3:23 am

    Create a file called savefiles.sh with the following contents:

    #!/usr/bin/bash
    
    cp $1 /path/to/BASE
    cp $2 /path/to/LOCAL
    cp $3 /path/to/REMOTE
    

    Execute the following command inside your repository:

    git config mergetool.savefiles.cmd "/path/to/savefiles.sh \$BASE \$LOCAL \$REMOTE"
    

    Add a --global if you want to change it for other than this repository.

    Then to run this custom mergetool, use:

    git mergetool --tool=savefiles
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file, foo.txt Create and checkout branch 'branch_A' git mv foo.txt bar.txt
What git command will display a list of all committed modifications, one modified file
After git pull I have done git reset hard to undo the merge with
Git has a bunch of procedures for altering history. ( rebase , filter-branch ,
On git-filter-branch , it is said: To set a commit (which typically is at
The Git-Gui has options setting (under Edit>>Options..) Is there a description somewhere of each
I currently have git and virtualenv set up in a way which exactly suits
I have an existing Git repository on Github. I wanted to reorganise my code,
I've been using TortoiseSVN on my development machine so far, and I find there
I am trying to use the paperclip plugin in my rails app to upload

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.