欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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

程序员文章站 2022-07-13 21:12:11
...

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.