Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij git revert a commit

I was using Eclipse and Egit for a long time and decided to try Intellij.
So far so good, except one thing...
I can't find an easy way to revert an old commit from my repo!!!

In Eclipse the standard process was: Go to Git Workspace -> Click Show History(Right Click Project) -> RIght-Click on the commit I want to revert and press Revert Commit.

In Intellij I can't find anything equivalent. Tried VCS -> Show Changes View but there I can only cherry pick a commit. I also played with the revert option under VCS -> git but got confused by the changelist thing(That may hide the answer, but I don't understand how it works).

I can still revert the commit by issuing git revert <sha> from terminal but that's what I was trying to avoid in the first place by using git from Intellij and not pure terminal.

Is there a way to do easily the revert in Intellij?

like image 447
dimzak Avatar asked Oct 03 '14 08:10

dimzak


People also ask

How do I undo changes in IntelliJ?

For most recent changes, including refactorings, press Ctrl+Z or choose Edit | Undo from the menu.


2 Answers

If you go to Changelist -> Log, and there select the commit, you've got a change detail in the right panel. There you can select all and click a button (or right click -> revert selected changes).

like image 69
c0stra Avatar answered Sep 29 '22 16:09

c0stra


I know of only one way and it's not as good as doing it command line.

First create a reverse patch. Go into the log, choose any commit and select create patch, check reverse patch and save it anywhere.

Then go into VCS menu and select apply patch and choose the file you just saved.

Commit those changes.

Still, I would go with doing it command line. Gives a proper automatic commit message as well.

like image 40
Andreas Wederbrand Avatar answered Sep 29 '22 16:09

Andreas Wederbrand