Unitech / pm2-deploy

Deploy part of PM2
http://pm2.keymetrics.io/docs/usage/deployment/
MIT License
178 stars 72 forks source link

Deploy failed: not a git repository (docs) #193

Open drthoben opened 3 years ago

drthoben commented 3 years ago

When deploying my Node.js application using a local ecosystem file which is not part of the repository from an arbitrary folder on my server I'm getting the following error:

$ pm2 deploy ~/pm2/server.yaml staging
--> Deploying to staging environment
--> on host localhost
Not a git repository
To compare two paths outside a working tree:
usage: git diff [--no-index] <path> <path>

  commit or stash your changes before deploying

Deploy failed
Deploy failed with exit code: 1

I've discovered that if I cd into the repository folder first and then run the deploy script, deployment works as aspected. I did not expect this behaviour and could not anything related to it in the docs therefore it would be nice if would be mentioned in the docs somewhere.

Maybe it's even possible that the deploy script cd's into the repository folder first before pulling.

I'm using pm2 v4.5.0.

akalter commented 3 years ago

I also have this problem. I am using pm2 v4.5.1 I saw the fix from this issue: https://github.com/Unitech/pm2-deploy/issues/23 I copied the fix into my code and it is working as expected.

mfn commented 2 years ago

I experienced the same issue today. In my case it wasn't because git diff detected changes, but because it didn't work at all. The local git, running in a vagrant machine (!), was running under a different user than the directories were and this triggered https://git-scm.com/docs/git-config/2.35.2#Documentation/git-config.txt-safedirectory

Once I fixed this git setting, it worked.

--force also worked, because it didn't ran the commands too.