0

I'm having a problem with git where it won't let me push or pull because of 'unmerged changes'. I tried to git rm the local files that have a conflict thinking I could just pull the remote ones and redo the changes but that made things worse.

I'm getting:

CONFLICT (modify/delete): xxx deleted in HEAD and modified in 03907b23b68fb8337d12d784b4415c. Version 03907b23b68d3f94f87 of xxx left in tree.
Automatic merge failed; fix conflicts and then commit the result.

How do I fix this and avoid it in the future?

pguardiario
  • 53,827
  • 19
  • 119
  • 159

1 Answers1

1

You can try using (THIS WILL DELETE ANY LOCAL CHANGES): git reset --hard HEAD to fully reset your working copy and index to HEAD in a pre-pull state. What this does is reset your entire repository to the HEAD state (you could specify any commit here), removing any merge information but also any local changes.

Read the docs to understand the details: https://www.kernel.org/pub/software/scm/git/docs/git-reset.html

Check this discussion for tips on merging with git to avoid problems in the future: How to resolve merge conflicts in Git?

Community
  • 1
  • 1
Nihathrael
  • 515
  • 1
  • 4
  • 13
  • 1
    Excellent answer IMO. Local changes have to be merged or discarded. What else is git supposed to do with them? – Vorac Sep 24 '13 at 09:54
  • Have you tried resetting it to a former commit, e.g. running `git reset --hard HEAD~` (note the *~*)? This will DELETE the HEAD commit, so if that contains unpushed changes, this is not for you. If you don't care about the last x commits (because they are in the origin repository anyway), try this option. – Nihathrael Sep 24 '13 at 13:02
  • I tried this too but same error. I decided to delete and re-clone the repo. – pguardiario Sep 25 '13 at 00:46