1

I first shallow-cloned a repo with depth=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 -

I then tried to unshallow the local clone by running twice this

if [[ ! -z "$(git rev-parse --is-shallow-repository)" ]]; then
    echo "STILL SHALLOW"
    git fetch $my_remote $my_branch --unshallow 
fi

I got "STILL SHALLOW" twice, and step by step still the same...

$ 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

So what am I doing wrong? how to use --unshallow ?

Guillaume D
  • 2,202
  • 2
  • 10
  • 37
  • read the first comment of [this](https://stackoverflow.com/a/17937889/313421) answer. – Xaqron Feb 13 '20 at 14:19
  • still the same error message ```fatal: --unshallow on a complete repository does not make sense``` – Guillaume D Feb 13 '20 at 14:29
  • Your bash script has problem. Run command in terminal. Your clone is not shallow anymore. – Xaqron Feb 13 '20 at 14:33
  • when running this line it does not work ```git fetch $my_remote --unshallow ``` (i have a different remote name than origin): ```fatal: --unshallow on a complete repository does not make sense``` but ```git rev-parse --is-shallow-repository``` returns ```--is-shallow-repository```. However ```git fetch $my_remote --depth=100000``` does fetch my files but does not remove the "shallow" attribute of the clone – Guillaume D Feb 13 '20 at 14:36
  • fatal error is a good thing in your case. It means clone is not shallow anymore. – Xaqron Feb 13 '20 at 14:40
  • it is not true, if I run ```rev-parse --is-shallow-repository``` again it still returns ```--is-shallow-repository``` – Guillaume D Feb 13 '20 at 14:40
  • 1
    Your git version doesn't have such an option for `rev-parse`. Run `git rev-parse --repo-is-not-shallow-anymore` – Xaqron Feb 13 '20 at 14:57
  • true! it returns anything!!! – Guillaume D Feb 13 '20 at 15:05
  • ```if [ -f $(git rev-parse --git-dir)/shallow ]; then``` – Guillaume D Feb 13 '20 at 15:07

1 Answers1

1

git rev-parse --is-shallow-repository is supposed to return true or false so using if [[ ! -z "$(git rev-parse --is-shallow-repository)" ]] always is treated as TRUE because even false (returned by command) is not an empty string.

It seems your version of git doesn't support rev-parse --is-shallow-repository sub-command and it turns out in that case any flag would be returned as output:

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

$ --repo-is-not-shallow-anymore

Because of following error your repo is not shallow and no further action is required:

fatal: --unshallow on a complete repository does not make sense

Xaqron
  • 29,931
  • 42
  • 140
  • 205
  • Note: `--is-shallow-repository` was added to `git rev-parse` in Git version 2.15. The OP must have a previous Git version. – torek Feb 13 '20 at 17:47