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).
Answer from c0stra on Stack OverflowIf 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).
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.
intellij idea - How to revert a unpushed git commit - Stack Overflow
intellij idea - How to revert commit file but not pushed - GIT - Stack Overflow
Git + Intellij - How to revert a local commit? - Stack Overflow
Undo multiple commits but keep local changes.
You can reset the head on your checked out branch to any hash you'd like in your history. It won't make changes to the files in your workspace without the -hard flag, so just do a reset to whatever commit you'd like, without passing it -hard.
This, of course, ignores whatever "Intellij" is, but you asked a question in "r/git", and that's how what you asked is addressed with Git.
More on reddit.comIn the latest version, you simply go to version control, right click the commit and select Undo Commit. This will put the changes back into a change list (so you can edit if needed) and remove the commit. You can remove the change list / revert the changes if you want them gone completely.
Using the Reset HEAD option should work too, just make sure to select a correct target and set an appropriate reset type (Mixed if you want to keep the changes, Hard if you want the changes gone too). To make it easier to find the target, you can find a Reset Current Branch to Here option when right clicking a commit in version control.
In that VCS > Git > Reset HEAD dialog from IntelliJ, you wanted to:
- select
Softas theReset Type(to keep the changes of the undone commit) - use
HEAD^as the commit (to point 1 commit back in the history of your branch)

That is equivalent to the following git command: git reset --soft HEAD^
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^
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.
Im working in enterprise and Ive never had to do this before . I accidentally pushed the target folder. How would I revert the commits without losing my changes safely in IntelliJ. I have googled but I am afraid in case it messes up my work
I need to delete the remote branch then back the changes. .
You can reset the head on your checked out branch to any hash you'd like in your history. It won't make changes to the files in your workspace without the -hard flag, so just do a reset to whatever commit you'd like, without passing it -hard.
This, of course, ignores whatever "Intellij" is, but you asked a question in "r/git", and that's how what you asked is addressed with Git.
Besides the suggested commands, you might also be interested in bfg_cleaner
Happened to me while getting both push and pull failures:
- "Push to origin/master was rejected"
- "You have not concluded your merge (MERGE_HEAD exists). Please, commit your changes before you can merge"
To resolve:
- Go to "Version Control" window --> "Log" tab.
- Right click the previous commit --> "Reset Current Branch to Here..."
- In Git reset select "Mixed" (it keeps local changes).
- If there are later commits that were already pushed --> Pull from remote and merge as required.
- Commit the new changes, and Push to remote.
In the latest versions of IntelliJ (and I suppose other JetBrains products) there is a new option in the "Git branches" menu (bottom right of the screen) conveniently named "Abort Merge"...
Update: with the so-called "New UI" of the more recent JetBrains products, the "git branches" menu has moved to the top left, but it is the same menu and the "Abort merge" option will still appear there when applicable.
