I found it. It found me...


I came across the only documentation about cloning a git repo with the --depth option, to create a "shallow" copy with the specified number of commits truncated from HEAD.

  if test fetch != "fast"; then
    log "full fetch"
    run "git clone $repo $path/source"
    log "fast fetch"
    run "git clone --depth=5 --branch $branch $repo $path/source"

Found in the source code of pm2-deploy.

Apart from the IRRATIONAL INVERTED IF STATEMENT ™ there, it seems to do it's job. (Why wouldn't you simply test for the truthy condition and invert both branches?)

Usage in pm2 ecosystem.config.js

I found that you can just specify "fetch": "fast" in your pm2 ecosystem configuration.

This means that it would fetch the last 5 commits from the HEAD (as you can see above).

Good enough for me.

  deploy : {
    production : {
      fetch: 'fast',
      user: 'node',
      host: '',
      ref: 'origin/master',
      repo: '[email protected]:repo.git',
      path: '/app',
      'post-deploy': 'npm install && pm2 reload ecosystem.config.js --env production'

If you know any place where this is documented, please reach on Twitter @christian_fei and send me a link 📖

Maybe a PR would be nice in the future, let's see.