this post was submitted on 25 Mar 2025
6 points (100.0% liked)

PhpStorm

80 readers
1 users here now

A community for the PhpStorm IDE for PHP developers! https://www.jetbrains.com/phpstorm/

Copyright © 2024 JetBrains s.r.o. PHPStorm and the PHPStorm logo are registered trademarks of JetBrains s.r.o.

founded 1 year ago
MODERATORS
 

@phpstorm "Local History" saves my *ss for a second time after I "reset hard" my git repo in the wrong folder containing quite some uncommitted code.

top 6 comments
sorted by: hot top controversial new old
[–] spartanatreyu 2 points 4 days ago

Two things:

  1. Learning git reflog will save you from needing to worry about the sudden dread that comes from using reset hard in git.

  2. Using an proper git client will save you needing to use reset hard in the first place. I highly recommend the confusingly named: Fork. It's free the same way that sublime text and winzip are: about once a month it asks for you to buy it but you can click on the "I'm still just trying it out" to keep using it for free.

[–] onlinepersona 2 points 5 days ago* (last edited 5 days ago)

Happened to me too and I panicked until I found LocalHistory. I think it was even a merge gone wrong after somebody had force pushed to a branch. What a crazy day that was.

Anti Commercial-AI license

[–] FizzyOrange 3 points 6 days ago (2 children)

Asking for it if you git reset --hard with uncommitted changes tbh... I feel like Git shouldn't let you do that by default, but that would make Git slightly user friendly so I guess we can't have that!

Glad you recovered your code anyway!

[–] [email protected] 2 points 5 days ago

@FizzyOrange Oh why this should not happen is a material to a whole book or at least a conf talk :D you know, commit at least daily, you should not have a 3d task worth of code and etc.

And what is the karma roundhouse-kick - I've been preaching about the bus factor in my team myself :D

[–] Kissaki 1 points 5 days ago (1 children)

How would you discard all/numerous changes without a hard reset?

[–] FizzyOrange 1 points 5 days ago

I normally click the "discard all changes" button in VSCode and it asks me if I am sure. That confirmation dialog has saved me a few times!

From the command line I'd normally git checkout . and git clean -ffxd. I guess you could say it's no different to git reset --head HEAD in a sense...