在遠程使用了git pull origin main:main命令后,出現(xiàn)下面的錯誤:
# git pull origin main:main
Password for 'https://347340@github.com':
remote: Enumerating objects: 11, done.
remote: Counting objects: 100% (11/11), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 6 (delta 4), reused 6 (delta 4), pack-reused 0
Unpacking objects: 100% (6/6), done.
From https://github.com/347340/blog
be6f3ac..b25ae08 main -> main
be6f3ac..b25ae08 main -> origin/main
warning: fetch updated the current branch head.
fast-forwarding your working tree from
commit be6f3ac9953448f26b1745b6be8dd20a32560126.
error: Your local changes to the following files would be overwritten by merge:
app/views/articles/show.html.erb
Please commit your changes or stash them before you merge.
Aborting
fatal: Cannot fast-forward your working tree.
After making sure that you saved anything precious from
$ git diff be6f3ac9953448f26b1745b6be8dd20a32560126
output, run
$ git reset --hard
to recover.
1. 本地倉庫所在的目錄下,先保存本地修改
2. 執(zhí)行這個命令,來清除本地修改并回退到與遠程倉庫一致的狀態(tài)
git reset --hard
這個命令會刪除所有未提交的修改,所以在執(zhí)行這個命令之前先保存對本地的修改。
3.? 然后再執(zhí)行g(shù)it pull origin main:main 命令來拉取遠程倉庫的最新代碼,這會將遠程倉庫的main
分支合并到本地的main
分支。
4. 然后再重新提交你的代碼,就發(fā)現(xiàn)可以正常提交了文章來源:http://www.zghlxwxcb.cn/news/detail-635794.html
?文章來源地址http://www.zghlxwxcb.cn/news/detail-635794.html
到了這里,關(guān)于在進行g(shù)it pull操作時,存在本地文件與遠程倉庫發(fā)生沖突的情況的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!