views:

61

answers:

2

I want to version control my web server as described here, by creating a git repo out of my /var/www directory. My hope was that I would then be able to push web content from our dev server to github, pull it to our production server, and spend the rest of the day at the pool.

Apparently a kink in my plan is that Git won't respect file permissions (I haven't tried it, only reading about it now.) I guess this makes sense in that different boxes are liable to have different user/group setups. But if I wanted to force permissions to propogate, knowing my servers are configured the same, do I have any options? Or is there an easier way to approach what I'm trying to do?

+2  A: 

The git-cache-meta mentioned in SO question "git - how to recover the file permissions git thinks the file should be?" is the more staightforward approach.

The idea is to store in a .git_cache_meta file the permissions of the files and directories.
It is a separate file not versioned directly in the Git repo.

That is why the usage for it is:

$ git bundle create mybundle.bdl master; git-cache-meta --store
$ scp mybundle.bdl .git_cache_meta machine2: 
#then on machine2:
$ git init; git pull mybundle.bdl master; git-cache-meta --apply

So you:

  • bundle your repo and save the associated file permissions.
  • copy those two files on the remote server
  • restore the repo there, and apply the permission
VonC
VonC- Thanks for this, I'll try it out- but is the bundling necessary? Couldn't I retain my workflow (dev -> github -> production) and just checkin/checkout the metafile?
Yarin
@Yarin: no, the bundle is not mandatory. It is a neat way to transfer repo when no other transfer protocol are available though.
VonC
+3  A: 

Git is Version Control System, created for software development, so from the whole set of modes and permissions it stores only executable bit (for ordinary files) and symlink bit. If you want to store full permissions, you need third party tool, like git-cache-meta (mentioned by VonC), or Metastore (used by etckeeper). Or you can use IsiSetup, which IIRC uses git as backend.

See Interfaces, frontends, and tools page on Git Wiki.

Jakub Narębski
Thanks Jakub- can you explain to my why Git cares about the executable bit and only that?
Yarin
+1 for the extra links.
VonC
@Yarin: executable bit only? When you clone a all set of files from one system to another, the notion of "read only" or "read-write" is not exactly relevant (as you said in your question: different users/groups). But the notion of "executable" doesn't depend on users and groups and can be reused from system to (remote) system.
VonC
Ah right- that would make sense!
Yarin