Push rejected, source repository is a shallow clone. Unshallow it with `git fetch --all --unshallow` and try pushing again

I’m getting error

Push rejected, source repository is a shallow clone. Unshallow it with git fetch --all --unshallow and try pushing again.

when
git push git@heroku.com:<APP NAME>.git $CIRCLE_SHA1:refs/heads/master
is executed in circle.yml.

I then added
git fetch --all --unshallow
before it, but it still gives me the same error.

I then rebuild with SSH, accessed the build and executed
git fetch --all --unshallow
git push git@heroku.com:<APP NAME>.git $CIRCLE_SHA1:refs/heads/master
and the push succeeded…

so via SSH this is working but not via circle.yml.

after this, I have to cancel the build and if I run it again (Rebuild), it builds with no errors.

looks like the issue is on circleci side. any suggestions how to fix?

thanks, udo

I used the info in this great post to eventually add the following to my 1.0 circle.yml

The result code of which was the following (added to ‘dependencies’):

dependencies:
  pre:
    # ... previous code
    #
    # Shallow repo before the dependencies phase,
    # see https://stackoverflow.com/questions/44063155/missing-commits-in-repo-on-circleci-container
    - "[[ ! -s \"$(git rev-parse --git-dir)/shallow\" ]] || git fetch --unshallow"

…where pre: indicates ‘shell’ code to be run before the dependencies: phase.

Hope this helps anyone, although the above might have some caveats I do NOT fully understand ( SO link mentioned above by FelicianoTech)

thank you very much! this did the trick. I had the “unshallow” part in the deployment section…