23

Newbie Git question: I have a repo set up on bitbucket. I git fetched someone else's changes and would like to merge them with my own. However, when I try to git merge (or git merge origin/master), I get the message "error: Your local changes to the following files would be overwritten by merge:", and then a list of files I've changed. Having Git merge these changes is exactly what I want to do though.

ario
  • 1,727
  • 4
  • 19
  • 28
  • Possible duplicate of [How to ignore error on git pull about my local changes would be overwritten by merge?](http://stackoverflow.com/questions/14318234/how-to-ignore-error-on-git-pull-about-my-local-changes-would-be-overwritten-by-m) – kenorb Mar 16 '16 at 12:45

2 Answers2

35

You can either commit your changes before you do the merge, or you stash them:

git stash
git merge origin/master
git stash pop
rtn
  • 127,556
  • 20
  • 111
  • 121
8

If you want to keep your changes, you can commit your changes to your local repository first and then merge the remote repository.

mamills
  • 1,786
  • 1
  • 15
  • 15
  • You can only merge on the remote repository, not locally? – ario Mar 06 '12 at 16:52
  • @ario, you will be able to merge (locally), **after** your local changes will be committed. Or else you will lose those changes. – ulidtko Mar 06 '12 at 16:55