Is it safe to run your site within a Git repository on your production server?

Back when I first started using SVN for version control I was told to use ‘svn export’ to always be running a clean copy of the code on the server.

With Git it seems like the best way to get my files on the server is just to have Git managing the application folders and tell it what tag I want it to be running. Is this an okay practice or is there a better way?

I would of course block .git/ from public access, but it feels weird having an active version of the Git repo on the production server. (Guessing I may be missing a step…)

Thank you for any insight you can help me with in this area.

Edit:
I currently use ‘svn export’ to a timestamped release folder that I symlink the public directory into with my deploy script.

  • Git workflow from local to bitbucket/github hub to live webserver
  • How can I have git not change file permissions?
  • How do I copy my entire website from testing area to webhost without breaking
  • How to add git hook to non /var/www folder
  • Git environment setup. Advice needed
  • Ubuntu automatically pull from Github repo
  • 3 Solutions collect form web for “Is it safe to run your site within a Git repository on your production server?”

    Instead of cloning your repo on the webserver as a normal non-bare repo, you should use a method such as this one. http://toroid.org/ams/git-website-howto

    One way would to organize your development and deploy process similar to the way in this post.

    You can configure Apache so he can’t serve a git folder. Something like:

    <Directorymatch "^/.*/\.git/">
    Order deny,allow
    Deny from all
    </Directorymatch>
    
    Git Baby is a git and github fan, let's start git clone.