2

I am new to Git and this is the first time I have experienced a merge conflict. I replaced an image, ran git commit and all was good. What I didn't realize was that a co-worker had done the same thing and commited their change to the remote repository. Then I ran git svn rebase (since we're using subversion) and I got myself into a state of conflict.

How can I simply "undo" my commit all together and accept the incoming changes?

Solution

Since I had already committed my change to my local repository, I needed to reset to the commit prior to my latest commit:

git reset --hard HEAD^

Now I am able to get the latest changes from remote:

git svn rebase
Community
  • 1
  • 1
Andrew
  • 227,796
  • 193
  • 515
  • 708

1 Answers1

0

If your commit is your last commit, you can just use git reset --hard <commit> to reset your repo to the commit before yours. Then just run git svn rebase again. You may also need to run get rebase --abort to get out of the current svn rebase operation.

Steve Prentice
  • 23,230
  • 11
  • 54
  • 55
  • so I did `git reset --hard HEAD`. `git status` showed that I was clean, but not on a branch. So I switched back to master branch. `git status` also shows clean. But when I do `git log` my commit is still there. What is going to happen when I run `git svn dcommit`? – Andrew Jun 16 '11 at 16:36
  • You need to reset --hard to a commit before your commit adding the image. Perhaps `git reset --hard HEAD^`? – Steve Prentice Jun 16 '11 at 16:48
  • yes! that worked. thank you. I was then able to `git svn rebase` without any issues. – Andrew Jun 16 '11 at 17:00