How To Fix Git Error Your Local Changes To The Following Files Would Be Overwritten By Merge When Pull Commits From Remote Repository

My project use sourcetree to push and pull commits from a git repository. When i pull a remote commit, i meet an error message like this : Your local changes to the following files would be overwritten by merge, Please commit your changes or stash them before you merge.

 * branch              master     -> FETCH_HEAD
error: Your local changes to the following files would be overwritten by merge:
    PythonExampleProject/.pydevproject
    PythonExampleProject/com/.../mongo/MongoDBConnect.py
Please commit your changes or stash them before you merge.
Aborting
Updating 31bddd97..ea752301
Completed with errors, see above

pull files from git repository error in source tree

After investigate, i finally find the method to fix this error, and the pull remote commits action perform successfully. Below is the steps.

  1. Select the files in sourcetree which are not committed to repository server.
  2. Right click them and click Reset to Commit menu item in the popup menu. This menu item will discard those not pushed committed changes.
    sourcetree reset to commit menu item
  3. Click OK button in the next 2 popup dialog. Then you can click the pull icon in top sourcetree tool bar to pull commits from remote repository.
READ :   How To Resolve Git Push, Pull, Merge Conflicts In Bitbucket Use SourceTree

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.