我有一个依赖于git子模块的项目。子模块也是我拥有的存储库,但是是从另一个用户的github存储库中克隆出来的。
The layout is:
my_project/
my_submodule/我想让我的子模块主分支保持干净,并且(可选)同步到其他用户的github存储库(它的主分支也是),这样我就不会搞砸它。但是我想在我自己的子模块的新分支中创建新的分支和新的提交,这样我就可以将PRs发送到github,并有一个"all_commits“分支,该分支保存了对子模块的所有更改,这样我就可以使用最新版本的my_project检查更改。基本上,我期待的是这个工作流:
$ cd my_submodule/
$ git switch main
$ git branch new_pr
$ git checkout new_pr
$ emacs somefile.cpp # change some file
$ git commit -a
$ git push -u origin new_pr
$ git switch all_commits
$ git merge new_pr # so all_commits holds all my prs and changes一旦公共关系被接受:
$ cd my_submodule
$ git switch main
$ git "sync" to orig_main # this is the command I am missing
$ git push -u origin main # store the new_pr change in my own repository
$ git branch -D new_pr # remove the new_pr now that it was accepted发布于 2022-11-12 01:06:18
缺少的一个步骤是用原始存储库刷新主分支(“其他用户的github存储库”)
$ cd my_submodule/
$ git switch main
$ # if not already done
$ git remote add upstream https://url/other/user/repo
$ git fetch upstream
$ # reset main to the other user's repo main branch
$ git switch -C main upstream/main
$ # create a new PR based on the latest from upstream/main:
$ git switch -c new_prhttps://stackoverflow.com/questions/74407772
复制相似问题