8

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

user3530827
  • 153
  • 1
  • 2
  • 8
  • 1
    i am using --assume-unchanged for the same purpose, and the whole point is to be able to change it later but not track those changes, but on a pull that error happens... seems like the pull should ignore merging those files you have marked, but it doesn't. I would love an answer to this too. – user1161137 Oct 07 '16 at 13:54

2 Answers2

1

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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

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

saccodd
  • 972
  • 9
  • 23