Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git + Intellij - How to revert a local commit?

Working with git and intellij I have accidently commmited my changes to my local branch.

I want to revert the commmit but keep the changes as before (ready for next commit).
I have looked in this page explaining me how to revert a commit but failed to understand the reset type meaning (mixed/head/soft).
I want to have all my changes as before in order to keep working on them.

Any help on how to it?

like image 936
Bick Avatar asked Feb 11 '15 07:02

Bick


People also ask

How do I revert a local commit?

The easiest way to undo the last Git commit is to execute the “git reset” command with the “–soft” option that will preserve changes done to your files. You have to specify the commit to undo which is “HEAD~1” in this case. The last commit will be removed from your Git history.

How do I undo changes in Intellij?

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


1 Answers

If it's a single commit that you want to place back into staging, then you can do the following command:

git reset --soft HEAD^

You can replicate that in IntelliJ through these steps:

  • VCS > Git > Reset HEAD
  • Change reset type to "Soft"
  • Change commit to HEAD^
like image 99
Makoto Avatar answered Sep 28 '22 17:09

Makoto