使用Git保留文件权限 [英] Retaining file permissions with Git
问题描述
我想按照我的web服务器的版本控制中所述的版本控制我的web服务器,通过从我的 / var / www目录
中创建一个git repo。我的希望是,我可以将我们的开发服务器上的网页内容推送到github上,然后将其提交给我们的生产服务器,并在游泳池中度过余下的时间。
显然我的计划中存在的一个问题是,Git不会尊重文件许可权(我还没有尝试过,现在只能阅读它)。我猜这是有道理的因为不同的盒子可能有不同的用户/组设置。但是,如果我想强制传播权限,知道我的服务器配置相同,是否有任何选项?或者是否有更简单的方法来处理我想要做的事情?
git-cache- meta
在SO问题中提到 git - 如何恢复文件权限git认为该文件应该是?(和 git FAQ )是更直接的方法。 这个想法是在 .git_cache_meta
文件中存储文件和目录的权限。
它是一个单独的文件,没有直接在Git仓库中版本化。
这就是为什么它的用法是:
$ git bundle创建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
所以你:
- 绑定您的回购和保存关联的文件许可权。
- 在远程服务器上复制这两个文件
- 恢复那里的repo,并应用权限
I want to version control my web server as described in Version control for my web server, 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 propagate, 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?
The git-cache-meta
mentioned in SO question "git - how to recover the file permissions git thinks the file should be?" (and the git FAQ) 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
这篇关于使用Git保留文件权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!