当前位置:   article > 正文

在进行git pull操作时,存在本地文件与远程仓库发生冲突的情况_after making sure that you saved anything precious

after making sure that you saved anything precious from $ git diff output, r

在远程使用了git pull origin main:main命令后,出现下面的错误:

  1. # git pull origin main:main
  2. Password for 'https://347340@github.com':
  3. remote: Enumerating objects: 11, done.
  4. remote: Counting objects: 100% (11/11), done.
  5. remote: Compressing objects: 100% (2/2), done.
  6. remote: Total 6 (delta 4), reused 6 (delta 4), pack-reused 0
  7. Unpacking objects: 100% (6/6), done.
  8. From https://github.com/347340/blog
  9. be6f3ac..b25ae08 main -> main
  10. be6f3ac..b25ae08 main -> origin/main
  11. warning: fetch updated the current branch head.
  12. fast-forwarding your working tree from
  13. commit be6f3ac9953448f26b1745b6be8dd20a32560126.
  14. error: Your local changes to the following files would be overwritten by merge:
  15. app/views/articles/show.html.erb
  16. Please commit your changes or stash them before you merge.
  17. Aborting
  18. fatal: Cannot fast-forward your working tree.
  19. After making sure that you saved anything precious from
  20. $ git diff be6f3ac9953448f26b1745b6be8dd20a32560126
  21. output, run
  22. $ git reset --hard
  23. to recover.

1. 本地仓库所在的目录下,先保存本地修改

2. 执行这个命令,来清除本地修改并回退到与远程仓库一致的状态

git reset --hard

这个命令会删除所有未提交的修改,所以在执行这个命令之前先保存对本地的修改。

3.  然后再执行git pull origin main:main 命令来拉取远程仓库的最新代码,这会将远程仓库的main分支合并到本地的main分支。

4. 然后再重新提交你的代码,就发现可以正常提交了

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/491363
推荐阅读
相关标签
  

闽ICP备14008679号