7

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?

Bick
  • 17,833
  • 52
  • 146
  • 251
  • I am not too sure about mixed, but "soft" is exactly like what you said, keeping the changes but having them as changes to be committed (think about it as what your previous commit would have looked like before you did `git add`). "hard" doesn't save any of those changes (think about it as rolling back those changes in soft) – Alaska Nov 20 '21 at 05:51

2 Answers2

13

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^
Makoto
  • 104,088
  • 27
  • 192
  • 230
0

There are three concept in Git, working directory, staging area and git repo. The parameters 'mixed/head/soft' you said corresponding to the three concept above. Parameter mixed only change the state of git repo, parameter soft change staging area and git repo, and the third parameter change all of three.

younghz
  • 66
  • 3