合并“上一个”后,Git 子模块未被跟踪分支
我的 git 存储库包含一个主分支,其中包含应用程序的开发版本,以及每个已发布(或当前测试)的应用程序版本的分支。
自上一个分支以来,我们向主(=开发)分支添加了一个子模块。
今天我必须对不包含子模块的最后一个分支进行一些更改。当我检查这个分支时,我总是收到警告“警告:无法 rmdir 路径/到/子模块:目录不为空”,并且当您执行“git status”时,“路径/到/子模块”将被列为“未跟踪” ”。 进行更改后,我总是确保在提交之前有选择地添加文件,这样我就不会意外地将“路径/到/子模块”添加到此分支。
当再次检查主分支并简单地使用“git merge”进行合并时,子模块现在在主分支中列为“未跟踪”。
查看 .gitmodules 子模块仍然被定义...
有关如何恢复它的任何提示?我需要重新初始化子模块吗?
干杯, 尼尔斯
My git repos contains a master branch with the development version of our application and a branch for each released (or currently tested) version of the application.
Since the last branch we added a submodule to the master (=development) branch.
Today I had to make a few changes on the last branch which doesn't contain the submodule. When I check out this branch I always get a warning "warning: unable to rmdir Path/To/Submodule: Directory not empty" and the "Path/To/Submodule" will be listed as "untracked" when you do a "git status".
After making changes I always make certain that I selectively add the files before committing, so that I don't accidentally add the "Path/To/Submodule" to this branch.
When checking out the master branch again and simply merge using "git merge " the submodule is now listed as "untracked" in the master branch.
Looking at .gitmodules the submodule is still defined...
Any hints about how to recover this? Do I need to re-init the submodule?
Cheers,
Niels
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不相信您会出现这些症状,除非在您上一个分支历史记录中的某个时刻跟踪该目录,然后由于某种原因进行 git rm 编辑。
话虽这么说,如果您现在重新初始化子模块,则下一次合并不应该再次删除它,因为
rm
提交已经被合并。这当然比尝试重写上一个分支的历史记录以便子目录从一开始就不存在要容易。I don't believe you would get those symptoms unless that directory was tracked at some point in your last branch's history then
git rm
ed for some reason.That being said, if you re-init your submodule now, the next merge shouldn't remove it again, because the
rm
commit has already been merged. That's certainly easier than trying to rewrite your last branch's history so the subdirectory was never present in the first place.