How to undo a commit in a local branch - git

I did some commits in a local branch through intellij in multiple git repositories. How can I undo those commits? I need the code changes after the undo (marked them as local changes).

4 comments
Comment actions Permalink

To undo local unpushed commits in Git you have to use the reset command. If you want to keep code changes, you need the "mixed" mode (which is the default mode).
There is also VCS | Git | Reset HEAD action in  IntelliJ IDEA, but it doesn't support multiple repositories.

1
Comment actions Permalink

I tried to follow what you said "VCS | Git | Reset HEAD"  but nothing changes when I do that. I get the a pop up (snapshot attached) to which I click "Reset". Nothing changes. The commit is not rolled back.

Did I misunderstood your solution?

Note - I am using Intellij 12.0.2 Ultimate edition



Attachment(s):
undo_commit.jpg
-1
Comment actions Permalink

Have you specified which commit to reset to? For example, if you want to roolback one commit, you should refer to HEAD^. Or you can specify the target commit hash.
I encourage you to read the link to the article I gave in the previous message, if you're not very familiar with git reset syntax.

0

Please sign in to leave a comment.