Search code examples
deploymentcodeshipshallow-clone

Deployment failed on codeship due to shallow clone


Codeship pulls a clone with a depth of 50 to speed up the build process. We had a pull request that was over 50 commits (uncommon but happens) and our deployment to catalyze failed with the following error:

 Warning: Permanently added '<deployment host>
 to the list of known hosts.
 Counting objects: 6551, done.
 Delta compression using up to 32 threads.
 Compressing objects: 100% (2626/2626), done.
 Writing objects: 100% (6551/6551), 23.57 MiB | 16.37 MiB/s, done.
 Total 6551 (delta 3843), reused 6551 (delta 3843)
 To <>.git
 ! [remote rejected] dev -> master (shallow update not allowed)
 error: failed to push some refs to '<>.git'

After squashing a few commits we were able to deploy but we ran into an issue when we had a rather large PR that needed to be merged. To avoid the error

 ' ! [remote rejected] dev -> master (shallow update not allowed) '

We added the following script to our deployment pipeline and everything worked fine.

 if [ -f ${HOME}/clone/.git/shallow ]; then git fetch --unshallow; fi

Solution

  • We added the following script to our deployment pipeline and everything worked fine.

    if [ -f ${HOME}/clone/.git/shallow ]; then git fetch --unshallow; fi