git update-index-假定未更改的文件的git pull错误 [英] git pull error for git update-index --assume-unchanged files
问题描述
我在执行git pull origin master
我有一些文件具有本地配置设置,并且与来源不同
我已将其标记为未通过代码跟踪->
git update-index --assume-unchanged html/index.php
I have some files which have local config settings and are different from origin
I have marked them as untracked by code->
git update-index --assume-unchanged html/index.php
现在,只要远程index.php文件没有更改,我就可以轻松地执行git pull
,但是当index.php文件更改时,我可以
git pull起源大师
我收到以下错误
branch master -> FETCH_HEAD
d532f8d..d01836e master -> origin/master
error: Your local changes to the following files would be overwritten by
merge:
html/index.php
Please, commit your changes or stash them before you can merge.
Aborting
Now as long as the remote index.php file does not change I can easily do git pull
, but when index.php file changes and I do
git pull origin master
I get following error
branch master -> FETCH_HEAD
d532f8d..d01836e master -> origin/master
error: Your local changes to the following files would be overwritten by
merge:
html/index.php
Please, commit your changes or stash them before you can merge.
Aborting
每当遇到此问题时,我都必须运行命令
git update-index --no-assume-unchanged [filepath/filename]
Whenever I face this issue I have to run command
git update-index --no-assume-unchanged [filepath/filename]
然后执行git pull,然后使用我的更改更新该配置文件,然后再次运行
git update-index --assume-unchanged html/index.php
then do git pull , and then update that config file with my changes and again run
git update-index --assume-unchanged html/index.php
我不需要在本地更改远程配置文件,因此无需更新这些文件 我无法更改远程文件,因此我可以在本地做什么,因为这些配置文件正在远程更新,因此我不会遇到问题
I do not need to take the remote config file changes in my local, so updating those files is not necessary I cannot change the remote file,so what can I do locally that I do not face an issue for these config files being updated in remote
推荐答案
我建议执行以下过程.让Git知道更改:
I'd suggest the following process. Let Git know about the changes:
git update-index --no-assume-unchanged html/index.php
隐藏这些更改:
git stash save "Save local conf"
您现在可以拉出然后恢复本地更改:
You can now pull and then restore your local changes:
git stash pop
,您可以接受本地更改来解决冲突.
and you can fix the conflicts accepting your local changes.
最后,我将使用--skip-worktree保护文件.为什么? 请参阅此处
Last thing, I'd use --skip-worktree to protect the file. Why? See here
这篇关于git update-index-假定未更改的文件的git pull错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!