繁体   English   中英

git 稀疏结帐和 github 的浅克隆问题

[英]git sparse checkout and shallow clone issue with github

想要从 git repo (github.com) 进行稀疏结帐。 更新(这个脚本现在可以工作了 - 技巧是在 pom.xml 之前添加“/” 制作这个 bash 脚本:

#!/bin/sh

export baseUrl=https://github.com/
export repoAc=spring-projects
export repo=spring-data-examples

#export baseUrl=https://github.com/
#export repoAc=tgkprog
#export repo=testGit

echo "Cd change to correct dir like ~/u/w/s/github/"
cd ~/u/w/s3/github/
if [ $? -eq 0 ]; then
    echo OK
else
    echo"FAIL: bad dir to cd to "
    exit 0
fi
echo "Have you edited this script? Else crl -c to stop now"
echo "you are at dir:"
pwd
echo "If exists contents of $repoAc/$repo :"
ls $repoAc/$repo
echo "1/2 will delete folder $repoAc/$repo ctrl-c to cancel. Press enter to continue"
read -rsp $'Press Ctrl-c to cancel or any other key to continue \n' -n1 key
echo "2/2 will delete folder $repo ctrl-c to cancel. Press enter to continue "
read -rsp $'Press Ctrl-c to cancel or any other key to continue \n' -n1 key
mkdir $repoAc
cd $repoAc
rm -fR ./$repo
git init $repo
cd $repo
if [ $? -eq 0 ]; then
    echo OK
else
    echo"FAIL: bad dir to cd to "
    exit 0
fi
# TODO if error stop here.
git remote add origin $baseUrl$repoAc/$repo
git config core.sparsecheckout true
echo "elasticsearch/*" >> .git/info/sparse-checkout
echo "/README.md" >> .git/info/sparse-checkout
#echo "h/" >> .git/info/sparse-checkout
#echo "s/" >> .git/info/sparse-checkout
echo "web/*" >> .git/info/sparse-checkout
echo "jpa/*" >> .git/info/sparse-checkout
echo "map/*" >> .git/info/sparse-checkout
echo "multi-store/*" >> .git/info/sparse-checkout
echo "/pom.xml" >> .git/info/sparse-checkout
#echo "!*/pom.xml" >> .git/info/sparse-checkout
#paths we do not want
echo "!no1/" >> .git/info/sparse-checkout
echo "!neo4j/" >> .git/info/sparse-checkout
echo "!cassandra/" >> .git/info/sparse-checkout
echo "!solr/" >> .git/info/sparse-checkout
git pull --depth=1 origin master 
#   wget https://raw.githubusercontent.com/spring-projects/spring-data-examples/master/pom.xml
echo "Done $repo"
ls -al

如果我从 echo "pom.xml"... 中删除行,直到 echo "solr/*" >> .git/info/exclude

我得到子目录:bom elasticsearch jpa map web

但不是父 pom。

如果我添加 echo "pom.xml" >> .git/info/sparse-checkout

然后它获取所有内容(所有子目录)。 不知道为什么?

更新 2:

早些时候正在尝试:

echo "cassandra/*" >> .git/info/exclude

意思是添加路径我希望 git 不结帐到文件 .git/info/exclude 但该文件仅用于添加和提交而不用于结帐。

对于结帐必须添加到文件 .git/info/sparse-checkout 像这样:

!卡桑德拉/

代码行:

echo "!cassandra/" >>.git/info/sparse-checkout

这样做。

使用“/pom.xml”,否则像 solr/pom.xml 这样的文件会被检出,创建需要的目录。

同样对于在结账过程中不应忽略的路径模式,将它们放在 .git/info/sparse-checkout 中,但在前面加上一个包 (!),例如:!cassandra/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM