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 7411121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:20:18+00:00 2026-05-29T06:20:18+00:00

I want to take advantage of the git-merge algorithm on two arbitrary files in

  • 0

I want to take advantage of the git-merge algorithm on two arbitrary files in a git repo. Here is my working directory:

folder/
    file1
    file2

file1 and file2 are similar, but I want to see how git would merge them as if they were different versions of the same file. In other words, I want something like this:

git merge-files file1 file2 > merge_of_file1_file2

Is there a way to do this?

  • 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-29T06:20:19+00:00Added an answer on May 29, 2026 at 6:20 am

    This doesn’t really make sense, because you’re not providing a common ancestor. If you do have one, however, you can use:

    git merge-file <current-version> <common-ancestor> <other-version>
    

    This places the results in the current version file; if you want them elsewhere, use:

    git merge-file -p <current> <common> <other> > <dest>
    

    It needs the common ancestor to provide something to consider changes relative to. You could hack it, by providing an empty file or a copy of an older version of one of them from the history of your repository, but the quality of results will depend on how well you select a common ancestor, since it’s merging the two diffs, between that and each of the new versions. An empty file will only work well if the two are very similar (many runs of at least three identical lines).

    Without that, all you can really do is look at the differences:

    git diff --no-index file1 file2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to take advantage of the new features in Windows 7 using C#
I'm using ActiveMerchant with Braintree as my payment processor. I want to take advantage
I want to create a game that will take advantage of multiple monitors. For
I want to take advantage of some jquery functions for sending messages like having
I want to take advantage of the new Windows 7 taskbar functionality in a
I want to take advantage of GCC's visibility attribute. To such end, in my
I have database table with the names of businesses and want to take advantage
I have stored a webpage's HTML in the database. I want to take advantage
Summary: I want to take advantage of compiler optimizations and processor instruction sets, but
We want to take advantage of nHibernate's Unit of Work functionality. To accomplish this

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.