由于未合并的文件,无法 git pull

JOH*_*JOH 5 git

我对 git 还是很陌生,并试图弄清楚一切是如何工作的。所以这是我的情况:我一直在我的笔记本电脑上开发一个 Java 项目。推送到 git 存储库并将其拉到另一台机器上。进行了一些更改并推送到存储库。现在我想将我当前的工作拉到我的笔记本电脑上,但它说我不能,因为我有未合并的文件。

Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
Run Code Online (Sandbox Code Playgroud)

请帮助纠正此问题。谢谢你。

$ git status
on branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

You have unmerged paths.
  (fix conflicts and run "git commit")
Run Code Online (Sandbox Code Playgroud)

Cod*_*ice 9

您有两个选择:完成当前合并或中止它。

  1. 要完成合并,您首先需要检查正在合并的文件。你可以这样做

    git status
    
    Run Code Online (Sandbox Code Playgroud)

    现在编辑文件以解决所有合并冲突。当您对已将代码恢复到工作状态感到满意时,您应该运行

    git add .
    git commit
    
    Run Code Online (Sandbox Code Playgroud)
  2. 另一方面,如果要中止当前合并并删除所有本地更改,则可以执行

    git reset --hard HEAD
    
    Run Code Online (Sandbox Code Playgroud)

    警告使用此命令要非常小心。它将删除您所有的本地更改,您将无法恢复它们。

最后,当您完成这些操作中的任何一个时,您可以继续拉动。