Search code examples
gitgit-merge-conflict

While taking pull from VS code.This conflict message pops up


$ git pull --tags origin development
* branch            development -> FETCH_HEAD
error: Your local changes to the following files would be overwritten by merge:
Please commit your changes or stash them before you merge.
Aborting.

I just need to know know how can i compare the changes that other user made along with mine and to accept both changes or revert accordingly.


Solution

  • The comment from git is pretty self-explanatory... one of the files you have modified in your working tree would be affected by that git pull so git is warning you about it and avoiding the merge because of it. The easiest way to deal with it is:

    git stash save "coming back"
    git pull --more-options-as-needed
    git stash pop
    

    Or, in your case, add --autostash in git pull. Notice the warning from git help pull:

           --autostash, --no-autostash
               Automatically create a temporary stash entry before the operation begins, record it in the special
               ref MERGE_AUTOSTASH and apply it after the operation ends. This means that you can run the
               operation on a dirty worktree. However, use with care: the final stash application after a
               successful merge might result in non-trivial conflicts.