简体   繁体   English

git push&pull文件权限更改

[英]Git push & pull file permission changes

I have a project on my production server linux1 . 我的生产服务器linux1上有一个项目。

  1. I copied the project from linux1 to my Windows PC with Windows FileZilla. 我使用Windows FileZilla将项目从linux1复制到了Windows PC。
  2. Then I copied it to my test server linux2 from my Windows PC with Windows Filezilla. 然后,将其从Windows PC和Windows Filezilla复制到测试服务器linux2
  3. On the linux2 test server I made some file permission changes on the files and also changed some of the code. linux2测试服务器上,我对文件进行了一些文件权限更改,还更改了一些代码。
  4. Then I copied the project from linux2 test server back to my Windows PC with Windows FileZilla. 然后,我将项目从linux2测试服务器复制到使用Windows FileZilla的Windows PC。

If I now push the project from my Windows PC to my Git repository, and if I then pull the project on my production linux1 server, will the file permissions on linux1 change? 如果我现在推从我的Windows PC上的项目,以我的Git仓库,如果我再拉我的项目在生产linux1服务器,将在文件权限linux1变化? Or will this just update the code? 还是只是更新代码?

Git only tracks one permission: the executable bit. Git仅跟踪一种权限:可执行位。 All files are stored as 644 (owner rw- , group and other r-- ) or 755 (owner rwx , group and other rx ). 所有文件都存储为644(所有者rw- ,group和其他r-- )或755(所有者rwx ,group和其他rx )。

When you pull on your production server files' executable bits will be updated according to how they were committed. 当您pull生产服务器文件时,可执行文件的可执行位将根据提交方式进行更新。 Other permissions and file ownership are not tracked. 不会跟踪其他权限和文件所有权。 The user doing the pull ing needs permission to modify the files on the local filesystem and will probably become the owner of any modified files. 进行pull的用户需要在本地文件系统上修改文件的权限,并且可能会成为任何已修改文件的所有者。

If you need further control over permissions you can run a script. 如果需要进一步控制权限,则可以运行脚本。 Alternatively, use a deployment tool that has more robust control over file permissions (that's not what Git was designed to do). 另外,请使用对文件权限具有更强大控制权的部署工具(这不是Git设计的目的)。

As a side note, it would probably be simpler to just use git clone / fetch / pull on your staging server instead of going through your Windows PC. 附带说明一下,仅在临时服务器上使用git clone / fetch / pull而不是通过Windows PC可能会更简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM