git init Permission denied – /private/etc/apache2

On OS X 10.10, I would like to use git with my apache in private/etc/apache2 directory. When I try to run git init I get Permission denied. What would a best practice be to add the appropriate permissions on this directory to enable git usage?

  • Should foo.xcodeproj/xcuserdata be ignored in git repo?
  • Installation of python libraries on OS X
  • OSX 10.10 yosemite beta on git pull: git-sh-setup: No such file or directory
  • Git shows file contents changed after clone
  • Git Clone Fails with sslRead() error on OS X Yosemite
  • Git on Yosemite keeps asking for remote username and password
  • yosemite svn 1.6.6 segmentation fault
  • Xcode6 quits unexpectedly
  • 2 Solutions collect form web for “git init Permission denied – /private/etc/apache2”

    The Permission denied is generally a file permission issue, where git doesn’t have permissions to write.

    One option is to run your git init etc with sudo, i.e., as sudo git init (though this is not recommended)

    You could also create a new user and a new group, add your web server user to that group and initiate git init with this user. Another alternative is to add yourself to the apache group using usermod

    As it is about to Permission Denied and @mu also mentioned about to use the sudo command,

    Give the permission of the folder to the user by the following command –

    $ chmod u+x /private/etc/apache2

    Git Baby is a git and github fan, let's start git clone.