简体   繁体   中英

Can't git pull because of unmerged files

I'm still very new to git and trying to figure out how everything works. So here's my situation: I've been working on a java project on my laptop. Pushed onto git repository and pulled it on a different machine. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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