我在远程存储库中有一些文件(即一些版本文件)不应被 future 的提交更改。有没有办法确保提交此文件的 future 用户将无法覆盖远程文件,但仍然能够推送。有没有比使用 githooks 更简单的方法来做到这一点?我不想创建一个撤消用户在 githook 中更改的提交。有更简洁的方法吗?
最佳答案
我认为根据你的需要你需要的是(我在这里可能错了)是:-
To temporarily ignore changes in a certain file: run
git update-index --assume-unchanged <file>
Then when you want to track changes again:
git update-index --no-assume-unchanged <file>
http://gitready.com/intermediate/2009/02/18/temporarily-ignoring-files.html
这会将文件保留在您的 git 存储库中。在该文件中所做的任何本地更改将无法添加、提交和推送到远程仓库。
关于git - 有没有办法阻止提交到远程存储库中的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41886051/