通过子回购(vim)推动本地git回购

通过子回购(vim)推动本地git回购,git,vim,bitbucket,git-submodules,pull,Git,Vim,Bitbucket,Git Submodules,Pull,我使用Vim和病原体作为插件管理器,我已经将许多插件克隆到了我的.Vim文件夹中。现在我希望我的自定义vim能够在多个系统上轻松访问,因此我将.vim目录设置为git repo。我用“git add”添加了所有内容,并将其推送到bitbucket存储库。现在,每当我想将这个repo克隆到另一台计算机上时,它只会创建插件所在的文件夹,而不会创建文件。我猜它们是自动添加为子模块的,但我似乎无法使用简单的命令(如“git submodule update”)将它们从各自的源代码中提取出来,它只是说“在

我使用Vim和病原体作为插件管理器,我已经将许多插件克隆到了我的.Vim文件夹中。现在我希望我的自定义vim能够在多个系统上轻松访问,因此我将.vim目录设置为git repo。我用“git add”添加了所有内容,并将其推送到bitbucket存储库。现在,每当我想将这个repo克隆到另一台计算机上时,它只会创建插件所在的文件夹,而不会创建文件。我猜它们是自动添加为子模块的,但我似乎无法使用简单的命令(如“git submodule update”)将它们从各自的源代码中提取出来,它只是说“在路径“bundle/plugin”的.gitmodules中找不到子模块映射”。 我需要做什么来防止这种情况?
提前感谢。

是的,您可以使用子模块将
.vim
的内容存储为Git repo,但我可以建议一种不同的方法

使用一个简单的脚本将插件克隆到
pathogen
期望的适当位置,可能更容易管理所有这些

我也在多台计算机之间工作,这种方法对我很有帮助

下面是我使用的(Perl脚本):

!/usr/bin/perl-w
严格使用;
我的$dotVimDir;
my$home=$ENV{home};
我的@repos=qw(
https://github.com/tpope/vim-fugitive|逃犯
https://github.com/tpope/vim-flagship|TPOP旗舰
#等等。。。
);
子运行命令($){
我的($command)=@;
打开CMD,“$command |”;
我的@output=;
关闭CMD;
返回@输出;
}
主要内容:{
我的$platform=$^O;
if($platform eq'linux'){
$dotVimDir=“$home/.vim”;
}elsif($platformeq'MSWin32'){
$dotVimDir=“$home/vimfiles”;
}否则{
打印“未知平台\n”;
出口1;
}
runCommand(“cp-R./vimplugins/autoload$dotVimDir”);
runCommand(“cp-R./vimplugins/ftplugin$dotVimDir”);
我的($repo,$folderName);
foreach(@repos){
($repo,$folderName)=拆分(“\Q |”,$|,2);
my$fullPath=“$dotVimDir/bundle/$folderName”;
如果(-d“$fullPath”){
runCommand(“git-C$fullPath stash-u”);
runCommand(“git-C$fullPath pull-origin-master”);
}否则{
runCommand(“git clone$repo$fullPath”);
}
}
出口
}
您可以将此脚本保存在一个单独的repo(可能称为类似于
myconfig
)中。我还将其他备用文件保存在此repo中(例如各种
自动加载
ftplugin
s),并且此脚本还复制这些文件


这也实现了这个目标。

你的
.vim
是你自己的,所以你可以告诉它你从哪里得到提交。既然你已经有了克隆,最简单的方法就是直接进行配置。默认值保存在
.gitmodules
文件中

git config -f .gitmodules submodule.fugitive.path fugitive
git config -f .gitmodules submodule.fugitive.url https://github.com/tpope/vim-fugitive.git
诸如此类。熟悉shell功能,使小型生产运行变得方便:

make-github-submodule () {
        git config -f .gitmodules submodule.$1.path $1
        git config -f .gitmodules submodule.$1.url https://github.com/$2.git
}

make-github-submodule fugitive tpope/vim-fugitive
make-github-submodule vundle VundleVim/Vundle.vim

诸如此类,看起来很方便。

这可能是一个很好的解决方案,我一定会看看这个!
make-github-submodule () {
        git config -f .gitmodules submodule.$1.path $1
        git config -f .gitmodules submodule.$1.url https://github.com/$2.git
}

make-github-submodule fugitive tpope/vim-fugitive
make-github-submodule vundle VundleVim/Vundle.vim