1. 程式人生 > >git merge 報錯:error: Your local changes to the following files would be overwritten by m

git merge 報錯:error: Your local changes to the following files would be overwritten by m

error log:

error: Your local changes to the following files would be overwritten by merge:
	app/Http/Controllers/User/UserIndexController.php
Please commit your changes or stash them before you merge.
Aborting

  

You can't merge with local modifications. Git protects you from losing potentially important changes. You have three options.

  • One is to commit the change using
git commit -m "My message"

  

  • 2.The second is to stash it. stashing acts as a stack, where you can push changes, and you pop them in reverse order.

To stash type:

git stash

  

  Do the merge, and than pull the stash:

git stash pop

  

  • The third options is to discard the local changes using 
git reset --hard.