从错误的分支中拉取Git

4

我在服务器上有两个分支,一个叫做R2,另一个叫做DEV。我不小心登录到了错误的服务器,并进入了仓库,执行了一次GIT PULL ORIGIN DEV操作,但是该仓库实际上是在R2分支上的。所以我意识到我的错误,并试图通过执行GIT PULL ORIGIN R2来纠正错误。然而,最终我遇到了一堆文件名和错误信息。

U   view/private_api/ipn.phtml
M   view/reports/menScholarshipForm.pdf
M   view/reports/printProCard.phtml
M   view/reports/printSanction.phtml
M   view/sanctionDetailRoster.html
M   view/sanctionDetailVerify.html
M   view/verifyMembership.phtml
Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution, or use 'git commit -a'.

我不介意逐个手动重置每个文件,只是不确定如何修复我的错误。 谢谢

1个回答

6

git pullgit fetch 后跟着 git merge FETCH_HEAD 的简写。看起来你在 git merge 阶段遇到了一些冲突。

git merge --abort 将会中止合并过程并尝试重建合并前的状态。

要将 R2 重置为 origin/R2 中的内容,请使用reset命令。

git checkout R2
git fetch origin
git stash # because it's always a good thing to do
git reset --hard origin/R2

[*****@dev app]$ git checkout R2 controller/AddCompetition.php: 需要合并 controller/Competition.php: 需要合并 controller/EditCompetition.php: 需要合并 controller/includes/proSearchWS.php: 需要合并 - Matthew Colley
1
谢谢Johnsyweb - 这解决了问题,希望其他遇到这个问题的人能看到这篇帖子和你的答案。 - Matthew Colley
中止合并就足够了。谢谢。 - Wok

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接