0

I'm rebasing my branch on origin/master using

git pull --rebase origin master

Now I get some merge conflicts regarding git submodule updates:

diff --cc cpp_lib
index c14a3fe5,71b17a71..00000000
--- a/cpp_lib
+++ b/cpp_lib
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit c14a3fe5ad7b3034b9744c607c74c19e70b53da6
 -Subproject commit 71b17a718561e8c3ff25523be75c1b36d3a0e585
++Subproject commit f9b7854b5f347be99a265b4acc47b265425380fa

Since I'm not really attached to my changes to the submodule ref I would like to drop the change to the new ref that I introduced and go with their change. So essentially I want to drop out the update to the submodule from the commit's DELTA so there will also be no further merge conflicts. How can I do that?

1
  • If you want to rebase on top of an upstream, do not use git pull --rebase, but git fetch + git rebase. The two forms are not equivalent. git pull --rebase contains special/additional logic that could get you to lose local commits, if the remote happens to look as if its history has been re-written by dropping its last commits. For more details, I recommend reading this amazing answer by @BertF stackoverflow.com/questions/78802778/… Commented Mar 3 at 13:50

1 Answer 1

1
git checkout --ours cpp_lib
git add cpp_lib
git rebase --continue
  1. Reset the submodule reference to the upstream version

     git checkout --ours cpp_lib
    
  2. Mark the conflict as resolved

     git add cpp_lib
    
  3. Continue the rebase

     git rebase --continue
    
Sign up to request clarification or add additional context in comments.

3 Comments

theirs and ours are swapped during a rebase merge! If OP needs to keep the incoming changes, it should be git checkout --ours ccp_lib
@dani-vta thanks, you're absolutely right, I edited my answer
> theirs and ours are swapped during a rebase merge! yes, but they are always "swapped" during a rebase, not just during a "rebase merge" (which the OP is not using as far as we know)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.