Pergunta

I tried to do git stash on my production server using 'deploy' user, but it gives error as

/usr/lib/git-core/git-stash: 440: cannot create /app/app_name/.git/logs/refs/stash: Permission denied

The error doesn't show up for 'root' user.

what could be the reason for error and how to resolve it ?

Foi útil?

Solução

It depends on how you have created your repo.
Try it with a repo created with git init --shared, in order for multiple users of a same group to be able to access and write in your repo.

--shared[=(false|true|umask|group|all|world|everybody|0xxx)]

Specify that the Git repository is to be shared amongst several users.
This allows users belonging to the same group to push into that repository. When specified, the config variable "core.sharedRepository" is set so that files and directories under $GIT_DIR are created with the requested permissions.
When not specified, Git will use permissions reported by umask(2).

You would find more in "Using Git without Sudo in many accounts".

For your current repo, make sure that deploy has the right to access /app/app_name/.git.

The OP rtcoms confirms:

3 files were owned by root user. And it did work.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top