使用git版本控制仅更新和提交文件权限 [英] Updating and committing only a file's permissions using git version control
问题描述
只需将some.sh
文件转换为可执行文件(chmod 755 ...
),就可以更新权限,但不能更新内容.有没有一种方法可以将文件 commit 放入git,以便在 clone / checkout /上恢复/设置可执行位.拉?
Just turned an some.sh
file into an executable (chmod 755 ...
), the permissions were updated but not the content. Is there a way to commit the file into git, so that the executable bit will be restored/set on clone / checkout / pull ?
更新:如何跟踪新权限已提交给github
?
Update: how can I track that the new permissions were submitted to github
?
推荐答案
默认情况下,如果更改执行权限,git将更新执行文件权限.它不会更改或跟踪任何其他权限.
By default, git will update execute file permissions if you change them. It will not change or track any other permissions.
如果在修改执行权限时没有看到任何更改,则可能是git中的配置忽略了文件模式.
If you don't see any changes when modifying execute permission, you probably have a configuration in git which ignore file mode.
在config
文件的.git
文件夹中查看您的项目,您应该会看到类似以下内容:
Look into your project, in the .git
folder for the config
file and you should see something like this:
[core]
filemode = false
您可以在您喜欢的文本编辑器中将其更改为true
,或运行:
You can either change it to true
in your favorite text editor, or run:
git config core.filemode true
然后,您应该能够正常提交文件.只会提交权限更改.
Then, you should be able to commit normally your files. It will only commit the permission changes.
这篇关于使用git版本控制仅更新和提交文件权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!