Reputation: 1385
So I've been trying to revert to the a prior version of my project. But I keep getting merge conflicts when I do a git revert. Why on earth does this make sense? I'm saying "I want to revert to this prior version, exactly as it was then" and now it's saying I need to keep some of the current code. No, I want none of it, I screwed up my project somehow and think this earlier version wasn't screwed up. I know I should just be able to resolve these problems, but I've never done a massive merge conflict before, and I don't understand a lot of this Xcode code.
Also, if I revert a commit, do I go BEFORE or AFTER the commit? For instance...
Commit A, Commit B, Commit C, Commit D.
I revert Commit B. Where do I go? After A, or after B?
$ git revert 8873550de2b6c4bec42cfec4e98600736f01ffb9
error: could not revert 8873550... Grid view
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
Upvotes: 1
Views: 735
Reputation: 136909
I'm saying "I want to revert to this prior version, exactly as it was then"
Actually, you're not:
Given one or more existing commits, revert the changes that the related patches introduce, and record some new commits that record them.
Given this simple history
D [master]
|
C
|
B
|
A
git revert B
generates a new commit on top of D
that reverses the changes introduced in B
(see the example below). If the changes introduced in C
conflict with this new commit, you'll get conflicts.
if I revert a commit, do I go BEFORE or AFTER the commit
Neither. You'd end up with something like
E [master]
|
D
|
C
|
B
|
A
where E
's changes reverse C
's changes.
If you want to "go back in time" to B
you can use git checkout B
(which will result in a detached head, which generally isn't helpful if you want to make new changes from that point), you can use git reset
to move master
back to B
, making C
and D
eligible for garbage collection, or you can use git branch
to create a new branch at B
.
With the information in your question I can't tell which of these you want.
Upvotes: 4