“如何使用git”--“不允许”;用一个「--“单一分支”;克隆
我首先克隆了深度为1的回购协议“如何使用git”--“不允许”;用一个「--“单一分支”;克隆,git,shell,shallow-clone,Git,Shell,Shallow Clone,我首先克隆了深度为1的回购协议 cd $folder_path git init git remote add $my_remote $url_to_repo git fetch $my_remote $my_branch --depth=1 git reset --hard $my_remote/$my_branch cd - 然后,我尝试通过运行两次来取消本地克隆 if [[ ! -z "$(git rev-parse --is-shallow-repository)" ]]; then
cd $folder_path
git init
git remote add $my_remote $url_to_repo
git fetch $my_remote $my_branch --depth=1
git reset --hard $my_remote/$my_branch
cd -
然后,我尝试通过运行两次来取消本地克隆
if [[ ! -z "$(git rev-parse --is-shallow-repository)" ]]; then
echo "STILL SHALLOW"
git fetch $my_remote $my_branch --unshallow
fi
我有两次“仍然肤浅”,一步一步地还是一样
$ git rev-parse --is-shallow-repository
--is-shallow-repository
$ git fetch $my_remote $my_branch --unshallow
remote: Counting objects: 16, done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 16 (delta 8), reused 0 (delta 0)
Unpacking objects: 100% (16/16), done.
From ssh://my_git_url.git
* branch my_branch -> FETCH_HEAD
$ git rev-parse --is-shallow-repository
--is-shallow-repository
那么我做错了什么?
如何使用--unshall
?git rev parse--is shall repository
应该返回true
或false
所以使用如果[[!-z”$(git rev parse--is shall repository)]
总是被视为true
,因为即使false
(由命令返回)不是空字符串
您的git
版本似乎不支持rev parse--is shall repository
子命令,在这种情况下,任何标志都将作为输出返回:
$git rev parse——回购不再肤浅
美元——回购不再肤浅
由于以下错误,您的回购不浅,无需采取进一步行动:
致命:--在完整存储库上取消允许没有意义
阅读answer的第一条注释。仍然是相同的错误消息
致命:--unshall on a complete repository没有意义
您的bash脚本有问题。在终端中运行命令。你的克隆不再是浅层的。当运行这一行时,它不起作用。git fetch$my_remote--unshall
(我的远程名称与origin不同):fatal:--在完整的存储库上取消shall没有意义
但是git rev parse--是浅层存储库
返回--是浅层存储库
。但是,git fetch$my_remote--depth=100000
会获取我的文件,但不会删除克隆的“shallow”属性。您的git版本没有用于rev parse
的此类选项。运行git rev parse--repo不再是浅的
注意:--is shall repository
已添加到git版本2.15中的git rev parse
。OP必须具有以前的Git版本。