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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:05:10+00:00 2026-05-23T10:05:10+00:00

I had an interesting thing happen using git, wondering if anyone could explain it

  • 0

I had an interesting thing happen using git, wondering if anyone could explain it to me so I can understand better.

When doing a merge of multiple branches (A,B),

git merge A B

fails as non-fast-forward, while

git merge B A

worked well. Why would that be?

  • 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-23T10:05:10+00:00Added an answer on May 23, 2026 at 10:05 am

    Let’s assume that A is a strict, direct child of the current branch. Then assume that B is a strict, direct child of A.

    The octopus merge, which processes heads given as arguments from left to right, incrementally with respect to the tree, but independently with respect to the index succeeds without conflict if it tries to apply B and then A, but encounters a conflict if it does the converse.

    As per the git-merge manual, section MERGE STRATEGIES:

    octopus
       This resolves cases with more than two heads, but refuses to do a
       complex merge that needs manual resolution.
    

    For instance:

     ~                 $ git init testdir && cd testdir && echo "This is C" > myfile
     Initialized empty Git repository in /home/huitseeker/testdir/.git/
    
     ~/testdir         $ git add myfile && git commit -m "C" 
     [master (root-commit) f0c8c82] C
      1 files changed, 1 insertions(+), 0 deletions(-)
      create mode 100644 myfile
    
     ~/testdir(master) $ git checkout -b "A" && echo "This is A1" > myfile
     Switched to a new branch 'A'
     ~/testdir(A)      $ git commit -m "A1" myfile
     [A ac5b51c] A1
      1 files changed, 1 insertions(+), 1 deletions(-)
    
     ~/testdir(A)      $ git checkout -b "B" && echo "This is B1" >> myfile
     Switched to a new branch 'B'
     ~/testdir(B)      $ git commit -m "B1" myfile
     [B 5bc838c] B1
      1 files changed, 1 insertions(+), 0 deletions(-)
    
     ~/testdir(B)      $ git checkout master
     Switched to branch 'master'
     ~/testdir(master) $ git merge B A
     Fast-forwarding to: B
     Already up-to-date with A
     Merge made by octopus.
      myfile |    3 ++-
      1 files changed, 2 insertions(+), 1 deletions(-)
    
     ~/testdir(master) $ git reset --hard HEAD^^^
     HEAD is now at f0c8c82 C
     ~/testdir(master) $ git merge A B
     Fast-forwarding to: A
     Fast-forwarding to: B
     error: Entry 'myfile' would be overwritten by merge. Cannot merge.
     Merge with strategy octopus failed.
    
     ~/testdir(master) $ cat myfile
     This is A1
    

    Indeed, when fast-forwarding to A, the label of master has not been pushed forward, though the tree has.

     ~/testdir(master) $ git status
     # On branch master
     # Changes to be committed:
     #   (use "git reset HEAD <file>..." to unstage)
     #
     #  modified:   myfile
     #
    

    If, looking at the code of what the octopus merge does, I perform this manually (look above for hashes):

     ~/testdir(master) $ git reset --hard f0c8c82
     HEAD is now at f0c8c82 C     
     ~/testdir(master) $ git read-tree -u -m f0c8c82 ac5b51c
     ~/testdir(master) $ git read-tree -u -m f0c8c82 5bc838c
     error: Entry 'myfile' would be overwritten by merge. Cannot merge.
    

    In the other direction (merge B A), now, if you look again at the code of merge-octopus, it tries to detect the branch we are trying to add is already in the tree (second case of the for loop). Indeed, at the merge of A, it sees ac5b51c (a.k.a. A’s head) is the common ancestor of A and B, and aborts without doing the second read-tree.

    This behavior is consistent with the fresh version of git : though I’ve pointed to v.1.3.1, this is still happening with my version.

     ~/testdir(master) $ git --version
     git version 1.7.5.4
    

    tl;dr : you want your octopus merge branches to touch distinct files

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have run into an interesting issue using PHP's date() function. Haven't had any
Had an interesting discussion with some colleagues about the best scheduling strategies for realtime
We had a very interesting problem with a Win Forms project. It's been resolved.
Had a good search here but can't see anything that gets my mind in
I've run into interesting thing (works same in both Java and C#). Java code:
We just had an interesting experience in trying to link a set of code
I've had some interesting conversations recently about software development metrics, in particular how they
Had a coworker ask me this, and in my brain befuddled state I didn't
Had a page that was working fine. Only change I made was to add
I had used Server Explorer and related tools for graphical database development with Microsoft

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.