Travis-CI fix for error reference not a tree

In these scenarios:

  • git commit --amend
  • squash and force push over previous commits

Travis-CI may give an error like:

fatal: reference is not a tree: <commit id>
The command "git checkout -qf <commit id>" failed and exited with 128 during .


Travis-CI uses a default Git clone depth of 50. While their docs suggest changing the depth to 3, this can be too shallow for common Git use cases. We would suggest either not specifying the Git clone depth (using the default) or specifying a depth larger than the number of commits your team would ever squash and force push (overwriting prior commits). For example in .travis.yml:

  depth: 25
  quiet: true



Written by Michael Hirsch, Ph.D. //