1

Possible Duplicate:
Trouble merging with Git

I downloaded a git repo made some changes(deleted some files) and then commited it. Then I did git checkout -b "new branch". Here I didnt delete the files but I did make some changes and commited it. Now I went back to my master branch and tried to do a git merge new_branch_i_created but that said:

fatal: 'merge' 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 and make a commit, or use 'git commit -a'.

What am I doing wrong?

And if I try to checkout to the new branch from my master branch it says:

GDCatalog/.classpath: needs merge
GDCatalog/src/com/cyrilmottier/android/gdcatalog/CatalogActivity.java: needs merge
GDCatalog/src/com/cyrilmottier/android/gdcatalog/PagedViewActivity.java: needs merge
GreenDroid-GoogleAPIs/.classpath: needs merge
GreenDroid/.classpath: needs merge
GreenDroid/src/greendroid/widget/PagedView.java: needs merge
error: you need to resolve your current index first
Community
  • 1
  • 1
user1667307
  • 2,041
  • 6
  • 27
  • 32
  • How do I resolve the errors? What commands do I run to merge the second brach with the master branch – user1667307 Jan 05 '13 at 11:27
  • A question: what was the last command before trying to do `git merge`? Is the problem uncommitted changes preventing a merge, or a merge conflict during merge (for example there is `.git/MERGE_HEAD`)? – Jakub Narębski Jan 05 '13 at 14:39

1 Answers1

2

The error message from git say it all. You have un-merged changes between your two branches that need to be resolved before submitted the merge commit. Those merge conflicts happen because the file have been modified in the two branches.

To resolve this, you need to edit the files in conflict. For each file, you'll have to resolve the merge. The conflicts will be surrounded by <<<<<<<<<<<, =========== and >>>>>>>>>> markers. How you resolve them will depends on the changes (you may want to keep your changes, the changes in the remote branch or a combination of the two).

Once you've resolved all the conflicts, then you'll have to do git add for each file. And then git commit. The pre-filled commit message will indicate this is a merge commit and that there were some conflict resolved. You probably don't have to edit it unless your coding style mandate some particular formatting of your commit message.

So, to summarise, you'll have to do:

$ emacs GDCatalog/.classpath
... resolve conflict ...
$ git add GDCatalog/.classpath
... do the same for all other files ...
$ git commit
Jakub Narębski
  • 309,089
  • 65
  • 217
  • 230
Sylvain Defresne
  • 42,429
  • 12
  • 75
  • 85