34

I am using git version 1.7.11.msysgit.0

I created a repository under GitHUB and added a file called as README.md with some text content .

Later on , I have installed GIT Client , did a clone to get the server contents on to my machine .

Then I deleted the file README.md on to my local machine .

Now when I do git commit , I get this error

praveenk@MSIN-BT-100 /d/workspace/MYTestRepo (master|MERGING)
$ git commit ;
U       README.md
error: 'commit' is not possible because you have unmerged files.
hint: Fix them up in the work tree,
hint: and then use 'git add/rm <file>' as
hint: appropriate to mark resolution and make a commit,
hint: or use 'git commit -a'.
fatal: Exiting because of an unresolved conflict.

This is with git pull:

$ git pull;
U       README.md
A       One.txt
Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution, or use 'git commit -a'.

How to resolve these errors ?

codeforester
  • 39,467
  • 16
  • 112
  • 140
Pawan
  • 31,545
  • 102
  • 256
  • 434
  • 1
    So this happens when you create a repo on Github with checking the option `Initialize this repository with a README `. So the easiest solution would be not to check that option. **Else** clone that remote repo from Github rather than creating a new repo in local machine. **Else** follow what the error msg says and it will also find you a solution. :) – uday Jul 17 '12 at 16:55
  • So, any luck? If you accept one of the answers, please mark it as so. – F. Orvalho Jul 20 '12 at 07:28
  • 1
    CodeGnome, what's unclear about "I am new to git"? – thumbtackthief Apr 12 '13 at 20:36
  • The presentation of that error message has now changed in git 2.1 (august 2014). See [my answer below](http://stackoverflow.com/a/25097854/6309) – VonC Aug 02 '14 at 17:54

4 Answers4

44

Do this:

git merge --abort
git pull (to be sure you're up-to-date)

Now replace the contents of the README.md file with what you want it to say. If you don't want it at all, do git rm README.md

Then if you replaced the contents, commit and push those contents with:

git add README.md
git commit -m "comment"
git push
radek
  • 7,240
  • 8
  • 58
  • 83
wadesworld
  • 13,535
  • 14
  • 60
  • 93
12

Try:

 git reset README.md

I had a similar issue and this was the only thing that solved it.

dorien
  • 5,265
  • 10
  • 57
  • 116
  • this was the only solution that worked for me. I just got tired of mergetool, when in fact I had made a single line change. (in which in spite of the number of times, I choose to let mergetool know my choice (B), it never marked that as resolved) – Mahesh Oct 21 '20 at 11:39
3

While a git reset is a good solution, note that the warning message has now a better format (Git 2.1, August 2014)

See commit d795216 and commit c057b24 by Jeff King (peff):

The irregular line-wrapping makes this awkward to read, and it takes up more lines than necessary. Instead, let's rewrap it to about 60 characters per line.
The quotes around "commit" are clunky; the user doesn't care that this message is a template with the command-name filled in.

$ git commit
U       foo
error: commit is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit, or use
hint: 'git commit -a'.
fatal: Exiting because of an unresolved conflict.
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
-1

Images get requested by the browsers even if they have the display property set to none. To prevent this, you can implement the solution I mentioned before, but if you are going to be toggling the visibility of the image too much, adding and removing the image from the HTML can be an unnecessary cost of performance that you can avoid by using the display:none property.

Beep
  • 2,737
  • 7
  • 36
  • 85