Search code examples
gitbitbucket

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


I am not sure how to get rid of this error. I am using "bitbucket" to privately upload my projects but I am receiving the following error even though I have deleted all the changed files. I simply want to pull the files

error: Your local changes to the following files would be overwritten by merge:
    buf.cpp
    buf.h
Please, commit your changes or stash them before you can merge.
Aborting

This is the command I used:

git pull origin

Solution

  • Deleting a file is changing it. You want those two files to be "unchanged". If you want to keep any changes you've done (including deletion), you should either stash or commit. Stashing would require unstashing (git stash pop or git stash apply), while committing will probably result in a conflict which you must resolve. If you just want to revert any changes (throw them away, not interested in keeping them), you can git checkout -- buf.cpp buf.h to restore them, then try the pull.