Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/20.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 repo的本地工作副本,它需要进行一些更改才能用于本地测试,但我不希望在我执行add--all和commit时将这些更改发送到远程 基本上,这些文件是: /protected/config/* /protected/components/UserIdentity.php 我尝试将它们添加到.git/info/exclude,但是git status仍然显示更改(已经对文件进行了更改) 我需要文件留在远程,但必须在本地更改它们,并且不受例如pull的影响 有办法吗?本文作者提出了

我有一个git repo的本地工作副本,它需要进行一些更改才能用于本地测试,但我不希望在我执行
add--all
commit
时将这些更改发送到远程

基本上,这些文件是:

/protected/config/*
/protected/components/UserIdentity.php
我尝试将它们添加到
.git/info/exclude
,但是
git status
仍然显示更改(已经对文件进行了更改)

我需要文件留在远程,但必须在本地更改它们,并且不受例如
pull
的影响

有办法吗?

本文作者提出了一个解决方案:

git update-index --assume-unchanged <file>
错误,合并被中止


因此,不,如果上游有修改,它将不适用于git pull。

链接问题中的第三个答案可能是您最感兴趣的。我不认为将此标记为重复的意义,因为链接问题有很大不同,我已经在这里收到了相关的答案tooLooks good;拉后文件会保持不变吗?好的,应该对我有用哦,tnx
git update-index --no-assume-unchanged <file>
error: Your local changes to the following files would be overwritten by merge: