Live data from Hacker News

Git undo: We can do better

blog.waleedkhan.name

21–30 of 490 posts

Re: Git undo: We can do better

#21
post #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.

Can you explain what's tricky about it? For me, I just had to remember that "reflog" was the name for "history."

Once I did that, everything else is just regular git commands. Check out a "commit." Revert to a "commit."

Re: Git undo: We can do better

#22
> novice users are terrified of it. When they make a mistake, many would rather delete and re-clone the repository than try to fix it

In my experience most beginners use a GUI like Atlassian Sourcetree or the Github desktop client. It's a lot harder to make mistakes using the GUI in my experience.

I still really like this idea though; eventually a subset of the beginners wants to learn the git cli and that sure seems scary at first.

Re: Git undo: We can do better

#23
post #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.

I think this is the problem with any command which you only need once in a blue moon.

I always forget how to set up networking, because I don't do it often enough.

Re: Git undo: We can do better

#24

> 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…

Without that, this tool becomes a crutch at best, and a disaster waiting to happen at worst.

The underlying assumption here is that undo features make people bad at thinking. I suspect that might be true in a lot of cases, but I think we should give users the benefit of the doubt and start by believing that they're undoing something that they tried to reason about and made a mistake with rather than thinking they're just whacking in random commands hoping to hit the right one. The outcome might be the same but one is a little more kind.

However, a reasonable counter argument to that whole idea is that without an escape hatch giving users a sense of safety they'll never even try to use any features that they perceive as 'dangerous'. Not having the ability to roll back something they've tried means they won't try, and that keeps most git users from becoming experts. An undo feature is an immensely useful learning tool (so long as it always works as expected), which is exactly what you want if you think that people should be encouraged to learn.

Re: Git undo: We can do better

#27

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

Sometimes, it's really hard. Using the reflog is like looking through a pinhole.

When recovering from a bad merge conflict, you have a bunch of commits in your reflog which have the same name, and you need to decide which one you want. It's hard to look at the exact diff data and decide which one is appropriate.

It's not listed in the article, but it also enables a workflow where you check out parent commits many times along your branch of development and start new offshoots, and possibly amend commits with many descendants. It becomes nigh impossible to manage the reflog when there are so many commits with the same message but different content. The reflog itself also doesn't make it easy to recover lost descendant commits, only the given root commit.

Other scenarios: the reflog will not help recover where a deleted branch pointed to, and it won't help update multiple branches that pointed to the different positions in the same rebased stack of commits (the reflog for HEAD, anyways).

Re: Git undo: We can do better

#28

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 implica…

For some reason people love to defend the obscure and strange and oftentimes objectively terrible Git CLI. I’ve found Mercurial much more straightforward for my (mundane and boring but prevalent) use cases, and I lament that it isn’t more widely used.

Re: Git undo: We can do better

#30

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 implica…

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

I once knew how it worked with moderate level of detail, but I simply do not need anything advanced for my day-to-day work.

Post reply on HN