所以我从存储库 A 克隆了这段代码,并在代码中创建了一个子文件夹 B。我所有的工作都是在子文件夹中完成的,我想将子文件夹置于版本控制之下,但我从来不想将 B 中的更改推送到存储库 A。事实上,我认为我什至没有对存储库 A 的推送访问权限。如何我可以将子文件夹 B 放入存储库 B 中吗?
我听说过子模块,但当我尝试使用它们时遇到错误:(我现在位于子文件夹 B 中)
user@host:~/code$ git init
Initialized empty Git repository in /pathtosubfolder/code/.git/
user@host:~/code$ git submodule add .
repo URL: '.' must be absolute or begin with ./|../
user@host:~/code$ git submodule add ./
fatal: could not create work tree dir ''.: No such file or directory
Clone of '/pathtosubfolder/code/' into submodule path '' failed
user@host:~/code$ git submodule status
user@host:~/code$ rm -rf .git
user@host:~/code$ git submodule init
You need to run this command from the toplevel of the working tree.
谢谢!
最佳答案
- 使用您的代码创建 B 存储库
在您的 A 项目文件夹中执行以下操作:
git子模块添加git://repo-b-path.git代码
您必须在 A 存储库中使用“子模块”命令
关于git - 如何将 Git 存储库放入另一个存储库中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20479175/