忽略对属于 git 存储库的文件的更改

Ignoring change to a file which is part of a git repository

我必须对我的 git 存储库中的一个文件进行本地修改,但我不会提交该文件,否则会丢失我的修改。我也不想每次都 git 添加 -p 。 我将该文件添加到我的 git 忽略中,但这没有用。

你可以做到

git update-index --assume-unchanged [the path to your file]

您可以随时通过调用

来反转操作
git update-index --no-assume-unchanged [the path to your file]