我想在我正在进行的一个项目中使用钠库,但我需要有一点实践,并跟上它的步伐。但是,我也希望以我通常的方式在文件夹ext/下使用我的所有依赖项。
mkdir Test
cd Test
git init
git config core.sparsecheckout true
echo c++/ >> .git/info/sparse-checkout
git remote add -f sodium https://github.com/SodiumFRP/sodium.git
git pull sodium master这给了我测试根目录中的c++/文件夹,这个文件夹没有什么特别的帮助。我希望它在ext/文件夹中,并被命名为c++以外的其他东西。重命名文件夹会导致它被视为未跟踪的,这是不可取的,因为我可以通过从zip复制文件来实现这一点。
如果我创建一个ext/目录并在其中执行pull命令,那么c++文件夹仍然是在根目录中创建的,而不是执行拉命令的位置。
是否有一种方法可以提取特定的分支并将其复制到另一个名称的子目录中?
发布于 2015-03-18 13:45:32
我会这样做:
假设您有一个名为main的主项目存储库:
# for the sake of completeness
git init main
cd main现在,为依赖项添加一个文件夹,并使其成为稀疏签出:
# make and change to directory
mkdir ext
cd ext
# sparse checkout of c++ directory only
git init
git config core.sparsecheckout true
echo c++/ >> .git/info/sparse-checkout
# add remote repository and check it out
git remote add -f sodium https://github.com/SodiumFRP/sodium.git
git pull sodium master然后有一个稀疏签出,并将其作为子模块添加:
cd .. # go back to main repository
# add and commit submodule
git submodule add ./ext
git commit -m "Added submodule"我用git 1.9.1测试了它。
如果您愿意,可以添加另一个目录,使其具有如下布局:
main
+ ext # multiple external dependencies
| + sodium
| + .git
| + c++
+ src # main project source fileshttps://stackoverflow.com/questions/29099736
复制相似问题