我使用git包备份git存储库。在最近版本的git中,子模块的存储库元数据存储在父存储库的.git /模块中,而不是以前存储在子模块中的.git目录中。
当git-bundle在子模块中运行时,它会创建父repo的包,忽略子模块。
有谁能弄清楚这件事吗?
如何制作子模块的git包?
参考资料:关于git邮件列表的问题
编辑
在阅读了sschuberth的工作原理之后,我编写了一个脚本来进行测试,并可以验证它是否有效。我有一个备份脚本,它依赖于验证.git 目录的存在,以便知道它是否位于存储库的顶级dir中,因此在子模块开始使用.git 文件时会中断。如果有人知道推荐的方法是保证您在存储库的顶级文件夹中,我很感兴趣。我不知道我怎么会错过这个。
为了防止需要为子模块编写测试脚本的人感兴趣,我使用了以下脚本:
#!/bin/bash
git --version
mkdir super
mkdir subRemote
touch super/superFile.txt
touch subRemote/subFile.txt
cd super
git init
git add --all
git commit -am"Initial commit"
cd ..
cd subRemote
git init
git add --all
git commit -am"Initial commit"
cd ..
cd super
git submodule add ../subRemote/.git
git add --all
git commit -am"added submodule"
git submodule update
echo -e "\ngit log in super:"
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative --all
cd subRemote
echo -e "\ngit bundle:"
git bundle create ../../submoduleBundle --all --remotes
cd ..
cd ..
git clone --mirror submoduleBundle bundledSub/.git
cd bundledSub
git config core.bare false
git config core.logallrefupdates true
git remote rm origin
git checkout
cd ..
#------------------------------------------------
cd super
echo -e "\nfiles in super":
ls -alh
cd ..
cd super/subRemote
echo -e "\nfiles in super/subRemote":
ls -alh
cd ../..
cd bundledSub
echo -e "\nfiles in bundledSub":
ls -alh
cd ..发布于 2012-08-06 14:17:02
您确信运行git submodule update成功并且子模块中的.git 文件(不是目录)存在吗?在我的测试中,捆绑子模块的版本1.7.9.6很好。
如果您仍然因为某种原因而失败,一个解决办法是将子模块的存储库克隆到自己的工作树中,然后从那里运行git bundle (如git submodule status在超级项目中所示)。
发布于 2012-07-12 16:20:03
我不需要这样做,但是我怀疑您是按照通常的方式来这样做的--打包子目录(如果子目录有需要发送的更改),然后打包父存储库。
子模块只是另一个git存储库。
https://stackoverflow.com/questions/11454539
复制相似问题