Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

php

github

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

like image 276
user3530827 Avatar asked May 03 '16 06:05

user3530827


People also ask

What is assume unchanged in Git?

When the "assume unchanged" bit is on, the user promises not to change the file and allows Git to assume that the working tree file matches what is recorded in the index. If you want to change the working tree file, you need to unset the bit to tell Git.

How do I reindex Git?

To start update of all repositories, go to the Git Integration for Jira app Git Repositories tab then click Reindex All button. Once synchronization is started, the progress will be displayed on this tab.


2 Answers

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.

like image 54
VonC Avatar answered Sep 27 '22 22:09

VonC


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

like image 41
saccodd Avatar answered Sep 27 '22 23:09

saccodd