8

我正在为我的 MacVim 安装创建一个 git 存储库。我的存储库中的一些插件有自己的 .git 文件夹和存储库。问题是......当我尝试将这些文件夹之一添加到我的主存储库时,它什么也不做。

我猜:

我无法添加该文件夹,因为它本身就是一个 git 存储库。我必须添加为子模块或删除 .git 文件夹。

如何将我的子仓库添加为子模块?

bryan-mini:.vim bsaltzman$ git status
# On branch master
# Changes not staged for commit: 
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#   (commit or discard the untracked or modified content in submodules)
#
#   modified:   bundle/YouCompleteMe (modified content)
#   modified:   bundle/nerdtree (modified content)
#   modified:   bundle/ultisnips (modified content)
#
no changes added to commit (use "git add" and/or "git commit -a")   

// This 
bryan-mini:.vim bsaltzman$ git add bundle/YouCompleteMe/
//  OR THIS
bryan-mini:.vim bsaltzman$ git submodule add bundle/YouCompleteMe/
repo URL: 'bundle/YouCompleteMe/' must be absolute or begin with ./|../

bryan-mini:.vim bsaltzman$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#   (commit or discard the untracked or modified content in submodules)
#
#   modified:   bundle/YouCompleteMe (modified content)
#   modified:   bundle/nerdtree (modified content)
#   modified:   bundle/ultisnips (modified content)
#
no changes added to commit (use "git add" and/or "git commit -a")
4

2 回答 2

4

看起来您可能已正确地将这些存储库添加为子模块,但您已经更改/添加/删除了这些存储库中的文件。如果您 cd 进入 bundle/nerdtree 并执行“git status”,它应该会告诉您有什么不同。如果您将子模块恢复到干净状态,则顶级模块应该停止说“修改后的内容”

另外,您的命令:

git submodule add bundle/YouCompleteMe/

是不正确的。'git submodule add' 需要一个 repo url,如下所示:

git submodule add https://github.com/Valloric/YouCompleteMe.git

但是从您的输出来看,您似乎已经在某个时候正确地做到了这一点。您似乎正在使用 Pathogen 来管理您的子模块 - 它的文档应该可以很好地引导您完成这个过程。或者你可以切换到显然有一些优势的 Vundle(我个人仍然在 Pathogen 上)。

于 2013-12-09T16:26:52.243 回答
0

添加子文件夹中存在的存储库的正确方法是简单地执行:

git submodule add (repo url)在父文件夹中。

例如:

cd ~/.vim/bundle
git submodule add https://github.com/Valloric/YouCompleteMe.git
于 2016-08-20T20:21:55.547 回答