Live data from Hacker News

Git undo: We can do better

blog.waleedkhan.name

11–20 of 490 posts

Re: Git undo: We can do better

#11

How hard is `git reflog` `git reset --hard ` Or if you just want to move back 1 commit `git reset HEAD@{1}`

git reflog is hard enough so that I (a software engineer for 12 years and a git user for 10+ years) have to look up its syntax every time I need it.

Re: Git undo: We can do better

#12
Damn, this is such a GREAT idea. I've messed up repos a few times, and it's never good. It's always -- "what's the magic want I have to wave now"?

The truth is, while we use git every day, most people really don't understand how it works.

There I said it. And I'm not ashamed.

I don't really know how Git works. And I think I'm not the only one.

What does "git reflog" or "git reset --hard ...." do? What are the implications?

We don't really know.

I feel stupid. But hey, at least I'm honest.

Re: Git undo: We can do better

#14

How hard is `git reflog` `git reset --hard ` Or if you just want to move back 1 commit `git reset HEAD@{1}`

I don't think the issue is so much that it's "hard" as that it's "not undo."

As a general rule of thumb, command line tools often ignore decades of UX best practice that have grown up. One of those is that operations (particularly destructive ones) should be easily reversible. It recognizes that human error is common.

And having "undo" specifically recognizes that human error puts the user in an emotional state where restoring things via complex operations is inviting risk. A typo to `git undo` is unlikely to be another command. A typo in the SHA (or an @{2} instead of an @{1}) for `git reset` will compound the error.

... that having been said, I'm going to go add `git undo` as an alias for `git reset HEAD@{1}` right now.

Re: Git undo: We can do better

#16
post #8

> Here’s my theory: novice and intermediate users would significantly improve their understanding and efficacy with Git if they weren’t afraid of making mistakes. Here's something that happens when people are encouraged to make more mistakes: they make more mistakes. The piece where people are encouraged to learn from these mistakes is missing from the author's equation. Without that, this tool becomes a crutch at be…

I wouldn't be so harsh. I don't know a single program that was made worse by adding undo. Imagine a painting program without it. (I'm sure there are some artistic programs that do that but those would be mostly toys) Trying to learn from mistakes that can be solved by an undo on local repository are mostly in the realm of "be more careful", which is an impossible requirement to achieve in general.

The cost of adding undo is usually the cost itself (i.e. every operation the program can do must now be considered for its reversibility). Not every program justifies that cost, but I have also never seen a program that was made worse by adding it.

Re: Git undo: We can do better

#18

> Here’s my theory: novice and intermediate users would significantly improve their understanding and efficacy with Git if they weren’t afraid of making mistakes. Here's something that happens when people are encouraged to make more mistakes: they make more mistakes. The piece where people are encouraged to learn from these mistakes is missing from the author's equation. Without that, this tool becomes a crutch at be…

Making a mistake is an opportunity to grow by testing and validating your mental model of a system. If the price of a mistake is too high that is the same as saying the price of testing is too high. If you want to craft a world in which people can learn more from fewer mistakes then I think that is a laudable goal but here it sounds like you simply want to keep that high cost. Side note; Factorio is a game where the price of making a mistake in your build is having to pick a thing up and try again. Very low friction for most mistakes. People learn a lot in that game by making mistakes, myself included (two direction trains leads you down a path of evil by the way), and I think if you were to include friction into that system to prevent them from wanting to make mistakes at all the overall learning would go down.

Or for an entirely different example, are you also opposed to FPGAs? Should people be forced to not simulate circuits before sending them off to be fabricated, in the hopes that by making the mistake more painful they won't make as many?

Besides its not like people need more examples in their lives of situations where a mistake is not easily recoverable from.

So to answer your question; I certainly can't, I am a mistake based learner. If you can do better then please, please, do.

Re: Git undo: We can do better

#19
This seems like putting a training wheel on a training wheel. git is already the easiest to understand of any VCS that I've used, and it's somewhat hard to do something in git that can't be reversed. As the articles states, it's unlikely you'll ever lose your changes. Further, this doesn't seem to be that different of a concept from git reset, so why not learn reset instead of yet another command?

Re: Git undo: We can do better

#20

> Here’s my theory: novice and intermediate users would significantly improve their understanding and efficacy with Git if they weren’t afraid of making mistakes. Here's something that happens when people are encouraged to make more mistakes: they make more mistakes. The piece where people are encouraged to learn from these mistakes is missing from the author's equation. Without that, this tool becomes a crutch at be…

Making it possible to "play" safely is maybe the best way to help people learn.
Post reply on HN