Alohamora153
Alohamora153

Reputation: 23

Git revert giving both modified conflict

In my existing repo, i made a file new.txt for POC purpose. I added the text 'commit 1' to it, added it and committed it with message '1' and pushed onto master on origin. Then I added the text 'commit 2' to the text file, added it and committed it with message '2' and pushed onto master on origin. Then I added the text 'commit 3' to the text file, added it and committed it with message '3' and pushed onto master on origin.

My git log at this point showed this

commit 4589b94ecb6b19a8ecf3b1913fe51d5f6b0aca79 Author: shubham Date: Thu Aug 31 13:57:51 2017 +0530

3

commit 4b3f99bc6c36a6c409af7392d5b7bee6362cfdd1 Author: shubham Date: Thu Aug 31 13:57:29 2017 +0530

2

commit 8ad49853d12863ab48f28d741b97490036e35533 Author: shubham Date: Thu Aug 31 13:57:09 2017 +0530

1

commit 236094a2fe5886e1fad16ee785ee2a625d38a651 Author: shubham Date: Fri Jul 14 16:01:33 2017 +0530

initial commit added rest services sample classes

and the git status shows

On branch master Your branch is up-to-date with 'origin/master'. You are currently reverting commit 4b3f99b. (all conflicts fixed: run "git revert --continue") (use "git revert --abort" to cancel the revert operation)

nothing to commit, working directory clean.

Now i want to undo the second commit '2'. So i tried git revert 4b3f9. This gave an error error: could not revert 4b3f99b... 2 hint: after resolving the conflicts, mark the corrected paths hint: with 'git add ' or 'git rm ' hint: and commit the result with 'git commit'

I checked git status after this and its changed for some reason On branch master Your branch is up-to-date with 'origin/master'. You are currently reverting commit 4b3f99b. (fix conflicts and run "git revert --continue") (use "git revert --abort" to cancel the revert operation)

Unmerged paths: (use "git reset HEAD ..." to unstage) (use "git add ..." to mark resolution)

both modified:   new.txt

no changes added to commit (use "git add" and/or "git commit -a")

I don't understand what both modified means and how should i go about undoing a specific commit from a series of commits?

Upvotes: 1

Views: 4460

Answers (1)

Marina Liu
Marina Liu

Reputation: 38106

Git is reverting 4b3f99 now.

Since there is conflict for new.txt when reverting, you should modify the new.txt and finish the revert:

# modify and save the new.txt
git add .
git revert --continue

Now you finish the convert 4b399f.

Upvotes: 2

Related Questions