最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

git - How to drop changes to submodule ref from commit during rebase - Stack Overflow

programmeradmin2浏览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?

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?

Share Improve this question edited Mar 4 at 10:26 jonrsharpe 122k30 gold badges268 silver badges476 bronze badges asked Mar 3 at 13:14 gladesglades 4,9982 gold badges22 silver badges64 bronze badges 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/questions/78802778/… – dani-vta Commented Mar 3 at 13:50
Add a comment  | 

1 Answer 1

Reset to default 0
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
    
发布评论

评论列表(0)

  1. 暂无评论