1

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 ?

rtcoms
  • 783
  • 1
  • 8
  • 19

1 Answers1

0

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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • deploy user has read/write access ls -l .git total 400 -rw-r--r-- 1 root root 41 Nov 5 2012 RENAMED-REF drwxr-xr-x 2 deploy deploy 4096 Apr 29 2012 branches similar for other files/folders in .git folder. – rtcoms May 15 '13 at 06:17
  • @rtcoms I don't see how a user can have write access to a `-rw-r--r-- 1 root root`. You will have to change to rights or the owner/group of that git repo directory. – VonC May 15 '13 at 06:28
  • yeah , I missed that . 3 files were owned by root user. And it did work. Thanks – rtcoms May 15 '13 at 06:38