Rong Nguyen
Rong Nguyen

Reputation: 4189

Discard change from server

I follow this answer to not include local content to commit, by using this command:

git update-index --assume-unchanged  <filename>

but when someone change it and push to server, i will receive this message when pull from server:

error: Your local changes to the following files would be overwritten by checkout:
        <filename>
Please, commit your changes or stash them before you can switch branches.

Is there anyway to not apply change from server to local files?

Upvotes: 0

Views: 216

Answers (1)

Alex Wolf
Alex Wolf

Reputation: 20128

This is a known issue when trying to merge files which were ignored with update-index --assume-unchanged.

Sadly there is no clean solution, only workarounds.
You should revert the --assume-unchanged and then stash the changes so you can pull, after that you should pop your stash and resolve any possible merge conflicts.

git update-index --no-assume-unchanged <filename>
git stash
git pull
git stash pop
<Solve merge conflicts>

If you still want to ignore the file after that you can use update index --assume-unchanged again.

Hope that helps.


Note: If you have similar problems when switching branches after using assume-unchanged you should use skip-worktree (git update-index --skip-worktree <filename>).

You can find more information on this topic in this question and of course in the documentation for update-index.

Upvotes: 1

Related Questions