![](/img/trans.png)
[英]How to add a git submodule from other repo and merge it with local folder
[英]How to handle folder of git submodule which is marked as "untracked" in the host repo?
我有一个代码库,我想在其中添加另一个 repo 作为子模块来进行一些集成测试。 所以按照教程我跑了
git submodule add -b master git@gitlab.com:kramer65/whisky.git
之后,一个git status
给了我这个:
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitmodules
whisky/
nothing added to commit but untracked files present (use "git add" to track)
如您所见, .gitmodules
文件是新的,但.gitmodules
whisky/
文件夹也显示为未跟踪。 在此之后,我提交了.gitmodules
文件,但whisky/
文件夹仍然显示为未跟踪。
我该如何处理? 我是否需要将whisky/
文件夹也添加到“主机存储库”中? 还是我需要将它添加到.gitignore
? 或者有另一种方法来处理这个吗?
欢迎所有提示!
只需重新运行git submodule add <URL>
。
Git 会将whisky/视为子模块,并且不会跟踪其文件。
您可以通过git diff --cached whisky/
来检查它(git 只会将其视为特定提交)
毕竟,只需提交即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.