1

我首先浅克隆了一个深度=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
    echo "STILL SHALLOW"
    git fetch $my_remote $my_branch --unshallow 
fi

我得到了两次“STILL SHALLOW”,一步一步还是一样……

$ 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

那么我做错了什么?如何使用--unshallow

4

1 回答 1

1

git rev-parse --is-shallow-repository应该返回truefalse使用if [[ ! -z "$(git rev-parse --is-shallow-repository)" ]]always 被视为TRUE因为 even false(由命令返回)不是空字符串。

看来您的版本git不支持rev-parse --is-shallow-repository子命令,事实证明,在这种情况下,任何标志都将作为输出返回:

$ git rev-parse --repo-is-not-shallow-anymore

$ --repo-不再是浅的

由于以下错误,您的回购并不浅,不需要进一步的行动:

致命的:--unshallow 在完整的存储库上没有意义

于 2020-02-13T15:14:49.127 回答