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
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.
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.
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
.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With