5

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")
JOH
  • 61
  • 1
  • 1
  • 7
  • Are you using the command line or a GUI tool? If the command line, please post the output of `git status`. – Code-Apprentice Nov 05 '14 at 04:36
  • So you don't care about any local changes you have in your attempt at merging? You're happy to overwrite your local stuff with the remote? – Simon Whitehead Nov 05 '14 at 04:36
  • @Simon Yes. I just want to update (overwrite) everything with everything on remote branch. – JOH Nov 05 '14 at 04:42
  • Did you purposefully leave off the list of files with conflicts in the output of git status? Or are none listed? – Code-Apprentice Nov 05 '14 at 17:21
  • Does this answer your question? [Why does git say "Pull is not possible because you have unmerged files"?](https://stackoverflow.com/questions/26376832/why-does-git-say-pull-is-not-possible-because-you-have-unmerged-files) – Flimm Jan 03 '22 at 12:35

1 Answers1

9

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.

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
  • How do you edit the files to resolve all merge conflicts? Pretty much all the files are giving me merge conflict. – JOH Nov 05 '14 at 04:53
  • 1
    @JinOh The same way you edit files to write code in the first place. You can use a simple text editor like NotePad, a beefier one like Notepad++ or Sublime Text, or a full out IDE like Eclipse or IntelliJ. The later might be preferable since they also have tools to help with a merge. – Code-Apprentice Nov 05 '14 at 06:02
  • Maybe I worded my question wrong. I wasn't asking how to literally edit the files. What do you need to edit so that I can merge? Or, I just want to replace all the local files with the ones in the repository. `git reset --hard HEAD` didn't work for me. – JOH Nov 05 '14 at 17:12
  • @JinOh The merge conflicts are clearly marked in the files. (Hint: look for unexpected compiler errors.) If you need more help, please describe what "didn't work" means. – Code-Apprentice Nov 05 '14 at 17:18