Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
忽略对属于git存储库一部分的文件的更改_Git - Fatal编程技术网

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

忽略对属于git存储库一部分的文件的更改,git,Git,我必须对一个文件进行本地修改,这是我的git回购协议的一部分,但我不想提交该文件,否则我的修改会丢失。我也不想每次都要git添加-p。 我将该文件添加到gitignore中,但这不起作用。您可以这样做 git update-index --assume-unchanged [the path to your file] 您可以通过调用 git update-index --no-assume-unchanged [the path to your file]

我必须对一个文件进行本地修改,这是我的git回购协议的一部分,但我不想提交该文件,否则我的修改会丢失。我也不想每次都要git添加-p。 我将该文件添加到gitignore中,但这不起作用。

您可以这样做

git update-index --assume-unchanged [the path to your file]
您可以通过调用

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