Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Doesn't look right if an article starts by introducing git reset and git reset --hard.



What makes you say that? I use that command nearly every day.


There is something wrong with your workflow if you have to use git reset --hard nearly every day.


Why in the world would you say that? I check out a branch, I write some code, it doesn't do what I want, I do a git reset and try again.

If you aren't using git reset that means you're either a genius coder who doesn't make mistakes, or you are a coder who would rather keep going down a bad path instead of just starting fresh. Some people find it easier to just start fresh.


For me, it's never the case that new code I'm writing is SO devoid of value I'd rather pretend I never wrote it, but that's what a reset does. Rather, I keep iterating until I've made clear progress, then commit.


Because git reset --hard is kinda dangerous, I've resorted to managing my changes with other safer commands. I undo changes with git checkout. Sometimes I stash and forget.

I only use git reset --hard when I have accidentally committed something to an incorrect branch and I want to reset that branch to point to a specific commit after creating another branch.

I strive for perfection in other areas of my like as well. :)


git reset --hard makes a lot of sense with printf debugging.

A typical workflow starts by adding printfs or whatever your equivalent is until you've narrowed down the bug. Then you fix the bug, keeping the printfs until the fix is confirmed. Then you use git gui or an equivalent tool to form the commit(s) for your bugfix. Finally, use git reset --hard to remove the debugging detritus.


Ok, I have to admit I've forgotten people actually (need to) do development/debugging like that.


I think this exchange between you two perfectly exemplifies why git is hard: everyone has a different interpretation of it.


It may seem hard if you don't know how to use it.


Now you have me really thinking.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: