31 Mar 2018

[Solved] Error: Your local changes to the following files would be overwritten by merge

In case you receive the following error while doing the git pull on the server :

error: Your local changes to the following files would be overwritten by merge:

filename.extension

Please commit your changes or stash them before you merge.

Aborting

There can be a possibility that you haven’t done any changes in the file on the server still the above error appears with every file you push on the server.

If you want to remove any local changes happened in the files due to file movement or permission change,  equate it to the current working head.

Use the following command to stash the changes :

git stash save --keep-index

If you don’t want those changes any more, just drop that stash too by :

git stash drop

Now, you can do git pull and will work fine.

In case you are receiving permission issues, then do check our blog post for .git permission issues.