当前位置:   article > 正文

[Git] git pull冲突和git stash pop冲突解决_git stash pop 冲突

git stash pop 冲突

一、git pull 冲突

代码仓有人提交了新代码,而我本地也修改了代码,想要pull一下,却发现:

error: Your local changes to the following files would be overwritten by merge:
        xxx.xxx
Please, commit your changes or stash them before you can merge.
  • 1
  • 2
  • 3

百度了一下解决办法很简单,有两种:

  1. 暂存本地的修改,pull之后解决冲突
  2. 撤销本地所有的修改,再pull

第一种办法:暂存本地的修改,pull之后解决冲突

git stash
git pull
git stash pop
  • 1
  • 2
  • 3

如果 git stash pop 遇见冲突,请见后文 git stash pop 冲突

第二种办法:撤销本地所有的修改

git reset --hard
git pull
  • 1
  • 2

二、git stash pop 冲突

git stash和git pull之后,想要git stash pop,却报错:

error: Your local changes to the following files would be overwritten by merge:
        xxx.xxx
Please, commit your changes or stash them before you can merge.
  • 1
  • 2
  • 3

报错原因:对 git pull 之后的代码有修改。

$ git status
	...
        modified:   test.txt
        modified:   work/workspace.xml
        modified:   work/ssss
        modified:   work/aaa
		...

$ git checkout .	# 撤销git pull之后的所有修改
# $ git checkout -- test.txt	 # 撤销test.txt的修改
# $ git checkout -- work/		 # 撤销work/目录下所有文件的修改


$ git statsh pop
Auto-merging user/views.py
CONFLICT (content): Merge conflict in user/views.py
The stash entry is kept in case you need it again.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/386936
推荐阅读
相关标签
  

闽ICP备14008679号