2

How do I fix the following?

<<<<<<< HEAD
<<<<<<< HEAD
-(int)existsMedia:(NSNumber*)mediaId {
 NSFetchRequest *request = [[NSFetchRequest alloc] init];
 NSPredicate *predicate = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"mediaId == %@", mediaId]];
=======
-(int)existsMedia:(NSNumber*)mediaMessageId {
 NSFetchRequest *request = [[NSFetchRequest alloc] init];
 NSPredicate *predicate = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"messageId == %@", mediaMessageId]];
>>>>>>> dc244e93b3e351ab6dce5785e1f2b686305a0051
=======
-(int)existsMedia:(NSNumber*)mediaMessageId {
 NSFetchRequest *request = [[NSFetchRequest alloc] init];
 NSPredicate *predicate = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"messageId == %@", mediaMessageId]];
>>>>>>> parent of 4a5c497... Bug Hunting for Media Support
 NSEntityDescription *entity = [NSEntityDescription entityForName:@"ELMMedia" inManagedObjectContext:managedObjectContext];
 [request setEntity:entity];
 [request setPredicate:predicate];
 NSError *error;
 NSUInteger count = [managedObjectContext countForFetchRequest:request error:&error];

 [request release];

Actually, yes, there was a merge. But I don't know why. Is it possible to get my correct commit on 00:25?

alt text

Henrik P. Hessel
  • 36,243
  • 17
  • 80
  • 100
  • I believe this is called merging with conflicts...? Subversion does the same thing. Your version is conflicting with the current version, and so it is trying to merge the changes. – Mitch Dempsey Aug 29 '10 at 23:34
  • That looks like the contents of a file which has merge conflicts but you don't say what the file is, what it looked like before or what git commands your ran so it's not easy to guess what happened. – CB Bailey Aug 29 '10 at 23:48
  • Did you, by any chance, amend a local commit, make another commit and then pull? – CB Bailey Aug 29 '10 at 23:50
  • Jup, I used several amend comits after a standard commit – Henrik P. Hessel Aug 29 '10 at 23:52

3 Answers3

2

Git found a merge conflict and modified the files in question to point out where the conflict is.

Edit the files resolve the merge, save, and commit them.

More info:


Edit

You say you didn't perform a merge, but a git pull includes a merge: based on your tree, it looks like you made changes to your local repository using an out-of-date copy. When you pulled the remote repository, it initiated a merge.

Resolving a merge is merely a matter of editing the files to look the way you want them to and re-committing, and is a standard part of SCM.

  • Well, the question is, how can my remote repo be out of date, when I'm the only one commiting to it Oo – Henrik P. Hessel Aug 29 '10 at 23:43
  • You were working off the wrong branch when you committed "Converted from Voice to more general Media Typ...". This happens from time to time if you're not careful, and the merge conflict being thrown is what prevents you from losing changes. You can always confirm you're on the right branch by doing `git status`. –  Aug 29 '10 at 23:46
  • Thanks, but I still have on branch setup. I'm confused. – Henrik P. Hessel Aug 29 '10 at 23:49
  • 1
    Look at your tree: you have two different branches (identified by the tags next to the top commit): `master` and `origin/master`. After the "Storage manager cleanup" branch, you made two commits to one, and one commit to the other. The topmost commit is the merge, which was initiated when you did something: either you did `git merge` or you did `git pull`. –  Aug 29 '10 at 23:53
1

Run git mergetool (assuming you set your mergetool tool in .gitconfig). It'll launch whatever tool you want to solve the problem.

alternative
  • 12,703
  • 5
  • 41
  • 41
1

Your problem is that you have pushed a commit to your remote repository, then amended it locally, made another commit and then pulled.

Because the remote repository contains an old 'version' of your amended commit, your new local commit is not a direct descendant of the remote branch. This means that pull will trigger a non-trivial (i.e. non fast forward) merge of the two branches. The old commit on the remote side and the amended commit that you have locally affect change the same areas of the same files so you have conflicts.

Assuming that you haven't (or don't mean to have) any local changes and that you want your most recent real commit ("Bug Hunting for Media Support") to be the head of the master branch you can undo the merge attempt like this.

I'm not 100% sure of you diagram, I believe that it means that you are attempting a merge but that you haven't made the merge commit yet. If so run this (be warned, this throws away local changes):

git reset --hard

If you have committed the merge (i.e. "-" is actually the commit message) then you would have to run git reset --hard HEAD^ instead.

After this your local master should be at the old commit.

If this is successdul, in order to get your remote repository correct, you will need to force the push. (This is usually not recommended but as you say that you are the only person using your repository it's OK.)

You should try this:

git push -f origin master

If this doesn't work (e.g. if the remote has denyNonFastForward set) you will have to resort to alternative means. See here for details of how to get around this.

Community
  • 1
  • 1
CB Bailey
  • 755,051
  • 104
  • 632
  • 656