merge的不同情况:

发布时间 2023-05-04 14:35:10作者: 妖山鬼店

1、场景1:同事修改了test.txt,提交。我修改了test.txt,接着马上输入git pull,出现提示:

问题:

error: Your local changes to the following files would be overwritten by merge:
test.txt
Please commit your changes or stash them before you merge.
Aborting
Updating b20f778..d0daa36

解决:(147条消息) error: Your local changes to the following files would be overwritten by merge 解决方案_躬匠的博客-CSDN博客

1) git stash # 封存修改

2) git pull origin master

3) git pull origin master # 把修改还原

这时,test.txt会变成上下两行的情况,类似:

<<<<<<<<<<

11111

>>>>>>>>

22222

修改成你自己想要的,比如只保留22222,然后git add, git commit, push即可。