user3530827
user3530827

Reputation: 153

git pull error for git update-index --assume-unchanged files

I am facing issues when doing git pull origin master

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

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

Whenever I face this issue I have to run command git update-index --no-assume-unchanged [filepath/filename]

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

Upvotes: 8

Views: 1973

Answers (2)

saccodd
saccodd

Reputation: 1067

I'd suggest the following process. Let Git know about the changes:

git update-index --no-assume-unchanged html/index.php 

Stash those changes:

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.

Last thing, I'd use --skip-worktree to protect the file. Why? See here

Upvotes: 1

VonC
VonC

Reputation: 1327364

Try using instead --skip-worktree:

git update-index --no-assume-unchanged -- a file
git update-index --skip-worktree -- a file

See "Difference Between 'assume-unchanged' and 'skip-worktree'" for more: --skip-worktree should better resist to git pull.

Upvotes: 1

Related Questions