tread
tread

Reputation: 11098

How to solve local changes to file overwritten when pulling after a git update-index --assume-unchanged?

I have a config file storing my local database connection details etc: application.ini.

After I initially pulled the project the application.ini file is tracked. So I decided to use:

git update-index --assume-unchanged application.ini

After which I made changes to the file regarding my mysql connection. All was alright and I am certain that the (tracked) application.ini file on the repo was changed so now when I use:

git pull

I get:

From github.com:username/repo
   669826e..64872d9  master     -> origin/master
Updating ef81735..64872d9
error: Your local changes to the following files would be overwritten by merge:
        application/configs/application.ini
Please, commit your changes or stash them before you can merge.

git status:

Your branch is behind 'origin/master' by 36 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)

nothing to commit, working directory clean

git stash save 'application.ini changes':

No local changes to save

Upvotes: 1

Views: 445

Answers (1)

ek9
ek9

Reputation: 3442

To revert --assume-unchanged, which is causing you problems, use --no-assume-unchanged.

Perform this command:

$ git update-index --no-assume-unchanged application.ini

Then before doing a pull, stash your local changes:

$ git stash

Do git pull:

$ git pull

Pop application.ini saved changes from stash:

$ git stash pop

Upvotes: 1

Related Questions