2013-12-09 249 views
2

所以我从存储库A克隆了这段代码,并在代码中创建了一个子文件夹B.我的所有工作都在子文件夹中完成,我想将子文件夹置于版本控制之下,但我从不想将B中的更改推送到存储库A.实际上,我认为我甚至没有对存储库A的推送访问权限。我可以将子文件夹B放入存储库B吗?如何把Git仓库放到另一个仓库中?

我听说子模块,但我得到的错误,当我尝试使用它们:(我在子文件夹B向右现在)

[email protected]:~/code$ git init 
Initialized empty Git repository in /pathtosubfolder/code/.git/ 

[email protected]:~/code$ git submodule add . 
repo URL: '.' must be absolute or begin with ./|../ 
[email protected]:~/code$ git submodule add ./ 
fatal: could not create work tree dir ''.: No such file or directory 
Clone of '/pathtosubfolder/code/' into submodule path '' failed 
[email protected]:~/code$ git submodule status 
[email protected]:~/code$ rm -rf .git 
[email protected]:~/code$ git submodule init 
You need to run this command from the toplevel of the working tree. 

谢谢!

+0

'你需要从工作树的顶层运行这个命令.' –

+0

如果你d不想推,不要推。 :P你拥有的是一个克隆 - 一个基本上独立的副本 - A.你可以在本地进行你想要的所有更改,甚至可以在别处完成并推送它们,而不需要知道。 – cHao

+0

谢谢! [15个字符] – Jessica

回答

4
  1. 与您的代码创建乙库
  2. 在您的项目文件夹做:

    git的子模块添加的git://repo-b-path.git代码

  3. 你必须努力工作在你的“子模块”命令中有一个回购

+0

非常感谢! [15个字符] – Jessica

相关问题