有没有办法阻止提交到远程存储库中的文件?

The*_*ear 2 git githooks

我在远程存储库中有一些文件(即某些版本文件),未来的提交不应该更改.有没有办法确保提交到此文件的未来用户将无法覆盖远程文件,但仍能够推送.有没有比使用githooks更容易的方法呢?我不想创建撤消用户在githook中更改的提交.这样做有更干净的方法吗?

小智 6

我认为根据你的需要你需要的是(我可能在这里错了)是: -

要暂时忽略某个文件中的更改:运行

git update-index --assume-unchanged <file>
Run Code Online (Sandbox Code Playgroud)

然后,当您想要再次跟踪更改时:

git update-index --no-assume-unchanged <file>
Run Code Online (Sandbox Code Playgroud)

http://gitready.com/intermediate/2009/02/18/temporarily-ignoring-files.html

这将保留您的git仓库中的文件.在该文件中进行的任何本地更改都将无法添加,提交并推送到远程仓库.