ario
ario

Reputation: 1787

How do you git fetch then merge? "Error: Your local changes to the following files would be overwritten by merge"

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.

Upvotes: 23

Views: 29551

Answers (2)

ralphtheninja
ralphtheninja

Reputation: 133118

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

git stash
git merge origin/master
git stash pop

Upvotes: 35

mamills
mamills

Reputation: 1806

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

Upvotes: 8

Related Questions