0

I’m trying to set up a workflow where my code base is version-controlled under Git, and then deployed to a live server over SSH.

I wrote a simple shell script that I run from my machine that opens an SSH connection and then executes git pull on the remote server. However, because this is being ran under root (don’t ask) all files and folders that are then created/updated by Git are given the user/group of root too, instead of apache.

How do re-assign apache as the user/group of these files/folders? Do I need to alter my workflow, or could I just run chown and chgrp after I’ve pulled from Git? Ideally, I’d like to just fix where I’d rather treat the problem though rather than treating the symptoms.

Martin Bean
  • 103
  • 1
  • 8

1 Answers1

0

You'ld better use another user than root. Anyway, use su -c or sudo to run git pull with the correct username

zecrazytux
  • 639
  • 3
  • 7
  • I know, but it’s a client’s server and that’s the only login they’ve given me. How do I use `su -c`/`sudo` to run `git pull` as `apache`? – Martin Bean Jan 17 '13 at 10:30
  • 1
    They gave you root access, so in effect it is NOT the only login the gave you. They gave you the keys to the kingdom. So now you can set it up correctly. – vgoff Jan 17 '13 at 11:15
  • So what is the correct steps to get Git to pull on the remote server, but not then assign everything it does the user/group of `root`? – Martin Bean Jan 17 '13 at 11:16
  • You might look at this setup. http://serverfault.com/a/234442/144062 – vgoff Jan 17 '13 at 11:51