开发者

What did Git do to my source code?

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 corre开发者_Go百科ct commit on 00:25?

What did Git do to my source code?


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:

  • Git Book - Basic Branching and Merging

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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜