Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't git pull because of unmerged files

Tags:

git

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")
like image 934
JOH Avatar asked Nov 05 '14 04:11

JOH


People also ask

How do I fix error pulling not possible because you have unmerged files?

To fix the “pulling is not possible” error, you can use git reset –hard. Always write a commit message after adding a file to Git's history. Ensure your files are updated to avoid conflict when pulling changes. You need to commit your changes or stash them before you can merge.


1 Answers

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.

like image 96
Code-Apprentice Avatar answered Sep 30 '22 04:09

Code-Apprentice