简体   繁体   English

由于未合并的文件而无法进行git pull

[英]Can't git pull because of unmerged files

I'm still very new to git and trying to figure out how everything works. 我对git还是很陌生,试图弄清楚一切如何工作。 So here's my situation: I've been working on a java project on my laptop. 所以这是我的情况:我一直在笔记本电脑上从事Java项目。 Pushed onto git repository and pulled it on a different machine. 推送到git存储库,并将其拉到另一台机器上。 Made some changes and pushed onto the repository. 进行一些更改并将其推送到存储库中。 Now I want to pull my current work onto my laptop but it's saying I can't because I have unmerged files. 现在,我想将当前的工作放到笔记本电脑上,但是我不能,因为我没有合并文件。

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

Please help on correcting this issue. 请帮助纠正此问题。 Thank you. 谢谢。

$ 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")

You have two choices: finish the current merge or abort it. 您有两种选择:完成当前合并或中止合并。

  1. To finish the merge, you first need to check what files are being merged. 要完成合并,您首先需要检查要合并的文件。 You can do this with 你可以这样做

     git status 

    Now edit the files to resolve all merge conflicts. 现在,编辑文件以解决所有合并冲突。 When you are satisfied that you have restored your code to a working state, you should run 当您对将代码还原到工作状态感到满意时,应运行

     git add . git commit 
  2. On the other hand, if you want to abort the current merge and remove all local changes, you can do 另一方面,如果要中止当前合并并删除所有本地更改,则可以执行

     git reset --hard HEAD 

    WARNING Be very careful with this command. 警告此命令要非常小心。 It will delete all of your local changes and you will not be able to restore them. 它将删除所有本地更改,并且您将无法还原它们。

Finally, when you have finished either of these actions, you can go ahead with your pull. 最后,当您完成上述任何一个动作后,就可以继续进行拉动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM