Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to revert a unpushed git commit

I am using Idea IntelliJ Community Edition 2016 and committed a change to GIT. But I have not pushed it. Now when I see my push queue I can see it in the queue. I tried RESET HEAD option but it did not work. I want to delete that commit. How can I do it in Intellij?

like image 409
codec Avatar asked Dec 23 '22 22:12

codec


2 Answers

In 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.

like image 159
gpgekko Avatar answered Jan 12 '23 17:01

gpgekko


  1. $ git commit -m "Something terribly misguided"
  2. $ git reset HEAD~
  3. << edit your files files as necessary >>
  4. $ git add ...
  5. $ git commit -c ORIG_HEAD
like image 45
Sjoerd Valk Avatar answered Jan 12 '23 17:01

Sjoerd Valk