0

I have problem with file permission when pulling down files from bitbucket using command : git pull origin master I am running this command with sudo rights, result - file owner become root, not apache user. any Ideas how to do to stay files in same level and owner stays apache?

Edgars
  • 1
  • 2
  • Possible duplicate of [How to keep git from changing file ownership](http://stackoverflow.com/questions/15076348/how-to-keep-git-from-changing-file-ownership) – Craig Otis Mar 03 '16 at 13:13
  • I do not see in this topi correct answer. After using this workaround [root@foo]# find /path/to/directory -type d -exec chmod g+s '{}' \; when I create new file file owner from (apache:apache) now are (root:apache) and default permissions now ar -rw-------. 1 root apache 0 Mar 3 15:24 test2.php – Edgars Mar 03 '16 at 13:40
  • Maybe someone could help me to understood how to do configurations on RedHat linux for folder to apply for newly created files or overwritten file same permissions as other files and folders inside this folder. Now permissions set -rw------- need something like -rwxr-xr-x – Edgars Mar 04 '16 at 07:30

1 Answers1

0

Git writes files as whoever's writing the files, i.e the current user. This issue might have been caused in the first place due to you cloning the repository with sudo rights. I suggest to change the ownership of the repository to your user and do the next pull without sudo rights. If the owner has to stay apache, the ownership should be changed to the user www-data and next the git pull should also be done using apache.

SachinSunny
  • 1,681
  • 1
  • 12
  • 20