Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete commit from locat git repository at phpstorm?

Tags:

git

phpstorm

I'm using PHPStorm and have a problem.

I've committed few files in PHPStorm (cmd+k). But it was a mistake and i shouldn't push'em. Now i don't understand, how to reset/delete that commit from phpstorm.

I used git reset --hard at Terminal, but nothing changed in PHPStorm - commit's still there. I can see it, if i'm trying to push (shift+cmd+k), then I see all previous commits.

like image 312
Petr Garmashov Avatar asked Dec 14 '22 15:12

Petr Garmashov


2 Answers

As long as the commit has not made it upstream yet, a command-line solution would be:

git reset HEAD^

The HEAD^ refers to the last commit before HEAD. HEAD represents the latest commit. When you use git reset without another argument, it resets to the latest commit. But that's exactly the point you're already at.

Adding --hard cleans up the added/edited files from your working directory. Decide for yourself if that's something you want.

like image 150
Joost Avatar answered Jan 13 '23 14:01

Joost


I have a Git button on the left-bottom of the IDE, if I click it I can see both my local and remote branches. If you click on a branch you can see all the commits in a timeline and you can delete them by just right-clicking on them and select Undo commit. Notice that you have to delete them in the order you added them.

like image 20
ALEX ARGENTE Avatar answered Jan 13 '23 14:01

ALEX ARGENTE