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

  • Home
  • SEARCH
  • 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

Git has a much-touted(?) octopus-merge capability that can merge many heads into one. But
Git works fine on my dev box, but ever so often, I'll go to
Git is implemented as a directed acyclic graph. Children know their parents but not
Our git server will be local, but we want an server where our local
In Git, how could I search for a file or directory by path across
git remote add joyent yourname.no.de:repo I'm assuming that this means it is using the
git status # On branch master # Changed but not updated: # (use git
GIT rm filename remove the file from the index as well as from your
Git newbie here. I am probably making a simple mistake here, but I can't
git pull --help says: In its default mode, git pull is shorthand for git

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.