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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:54:14+00:00 2026-05-18T10:54:14+00:00

Lets say I have two branches in RepoX called BranchA and BranchB. RepoX also

  • 0

Lets say I have two branches in RepoX called BranchA and BranchB. RepoX also has a submodule called SubmoduleY.

BranchA has SubmoduleY at revision ‘abc’, BranchB has SubmoduleY at revision ‘def’.

Say I want to merge BranchA into BranchB, but I want to leave BranchB’s SubmoduleY pointing to its original revision of ‘def’. I see a couple ways of doing this:

Method 1:

  1. Checkout BranchB.
  2. Move SubmoduleY to revision ‘abc’ to make the actual merge painless (we don’t want to do any merging at the submodule level right now).
  3. Commit the new revision for SubmoduleY (we can’t have it floating for the merge).
  4. Merge BranchA into BranchB. Resolve any conflicts.
  5. Move SubmoduleY back to revision ‘def’.
  6. Commit the new revision for SubmoduleY.
  7. Push changes up to the main repo.

Method 2:

Same as method 1, but instead of doing step 6, rebase and get rid of the extra submodule commit from step 3.

Both seem to have annoying drawbacks:

Method 1 puts two extra commits into history.

Method 2 forgets any changes to do with submodule revisions because those commits get removed. Therefore, any merges later on will have to deal with some problems again.

Is there a better way?

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

    You could do a variation on your method 1, but do the commit that introduces the change to the submodule version (in your step 6) with --amend so that it changes the state of the submodule in the merge commit. In other words, this would be:

    $ git checkout b
    $ git merge a
    Merge made by recursive.
     example.txt |    1 +
     sY          |    2 +-
     2 files changed, 2 insertions(+), 1 deletions(-)
     create mode 100644 example.txt
    $ cd sY
    $ git checkout def
    [... you get the "detached HEAD" warning ...]
    $ cd ..
    $ git add sY
    $ git commit --amend
    

    Note that I didn’t bother trying to avoid having the submodules at different versions before merging, as you suggested in your question. If there’s a conflict, you can just choose to add the submodule at def to resolve it. If there isn’t a conflict, the steps I mentioned above should work fine.

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

Sidebar

Related Questions

Lets say I have two tables - child and parent with many-to-one relation. What
For simplicity lets say I have two flex mxml pages. form.mxml button.mxml If the
Lets say I have two tables in Postgres: Name: table_rad Column Type id integer
Lets say I have these two tables: CREATE TABLE nodes ( id INTEGER PRIMARY
Lets say that we have two compilation units as follows: // a.cpp extern int
Let's say I have two models, Classes and People. A Class might have one
Let's say I have two arrays: int ArrayA[] = {5, 17, 150, 230, 285};
Let's say I have two tables: Report Comment And assuming I have a database
Let's say I have two existing tables, dogs and cats: dog_name | owner ---------+------
Let's say we have two classes, Foo and Foo Sub, each in a different

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.