News for hackers. Stuff that matters.
Re:Oh Shit, Git by toxik on Saturday June 25, 2022 @09:34AM (#31875182)
You shouldn’t present your own opinions as facts. I find Git intuitive, and it works as I expect it to do. I suspect a lot of people agree since Git became the champion of the DVCS crusades.
Re:Oh Shit, Git by amelius on Saturday June 25, 2022 @10:22AM (#31875528)
Good modern software always offers an undo option. Where is "git undo"?
Re:Oh Shit, Git by dahart on Saturday June 25, 2022 @11:32AM (#31876051)
It’s the first thing in the article. Git reflog. (BTW you won’t get any disagreement from me about the lack of intuitiveness of the command name. But, in a way, git’s whole reason for existing is to undo, and almost everything you do in git can be undone by design.)
Re:Oh Shit, Git by rfiat on Saturday June 25, 2022 @03:21PM (#31877937)
The reflog is very helpful but I don't think it counts as an "undo". Some operations (like git add or git push) won't show up in the reflog.

Even the operations which do show will often require more thought to undo than a hypothetical "git undo" would. I know how to use the reflog but I often go out of my way to avoid it because "git branch tmp HEAD; git $POSSIBLE_MISTAKE; git reset ---hard tmp; git branch -D tmp" requires less effort than deciphering the reflog's output.

Re:Oh Shit, Git by dahart on Saturday June 25, 2022 @04:40PM (#31878559)
Git reflog absolutely counts as the first step of undo for several workflows, but you’re right there are other commands needed for some kinds of undo.

Undoing a push does require a different set of commands, but my point, to the question @amelius asked, is that you can undo both push and add, and whatever other mistake you’re thinking of, difficult or not.

Re:Oh Shit, Git by amelius on Saturday June 25, 2022 @03:09PM (#31877829)
Of course, but Git keeps track of everything you undo, which at the meta level is something you can't easily undo ...
Re:Oh Shit, Git by dahart on Saturday June 25, 2022 @04:36PM (#31878523)
Maybe I misunderstood your question, what were you asking about above?
Re:Oh Shit, Git by toxik on Saturday June 25, 2022 @12:14PM (#31876438)
Ah yes, the classic `rm --undo` saved me so many times. No, command-line interfaces rarely offer undo. The onus is on the user to not do irreversible things when they may need to be reversed.

Git, coincidentally, does have something equivalent to undo history: the reflog.

Re:Oh Shit, Git by ogogmad on Saturday June 25, 2022 @12:39PM (#31876666)
"rm" was made in the '70s. Git was made in the '00s.
Re:Oh Shit, Git by toxik on Saturday June 25, 2022 @01:08PM (#31876895)
Nothing prevents rm from being made to “put in trash bin” in the year 2022. Your argument seems weak. rm removes. mv moves. If you want mv, use mv.
Re:Oh Shit, Git by amelius on Saturday June 25, 2022 @03:46PM (#31878131)
Nobody said that rm was perfect ;)
Re:Oh Shit, Git by _gabe_ on Saturday June 25, 2022 @11:38AM (#31876108)

  git reset HEAD~1 
Usually works good enough for me. Idk if this is the proposed way to undo stuff