Live data from Hacker News

Git undo: We can do better

blog.waleedkhan.name

241–250 of 490 posts

Re: Git undo: We can do better

#241
post #88

Earlier quoted context omitted.

That's a failing of Git. TortoiseSVN brought source control to millions of people. A good tool should be fully embeddable in a UI, 15 years after its launch.

We still use tortoiseSVN at work. It's crude but shockingly simple to use. Moving to git would be a significant expense just to train people not to break things and to get them used to CLI.

TortoiseGit exists too and is fantastic IMO: https://tortoisegit.org/

Re: Git undo: We can do better

#242

I'm sorry, but how many bits of git's UI do we have to force users to manually replace before we realize that the entire problem is git's UI? Between the tone deaf responses here about "using a GUI client is the problem," to the tone deaf responses of "you just have to learn it's internal architecture," it should be obvious what the problem is. The problem is not just being able to undo a mistake (though that's certa…

There is no doubt that a bunch of the general commands are really poorly named, or mixed together. `git checkout branch` means switch to a branch - that's fine. But `git checkout filename` means "undo changes to the file". What? That's totally insane. `git branch new-branch-name` means create a new branch. Great, but it doesn't check out the branch, which you want like 99.9% of the time. If you want to do that, you u…

Git checkout branch means change the entire working tree to the reflect the state of the branch and git checkout file, checkout the state of that file in HEAD. Both commands to the same thing, change the state of your working tree to reflect a point checked into version control.

It sounds like you are unaware of

  git switch branch
and

  git switch -c new-branch

Re: Git undo: We can do better

#243

I'm sorry, but how many bits of git's UI do we have to force users to manually replace before we realize that the entire problem is git's UI? Between the tone deaf responses here about "using a GUI client is the problem," to the tone deaf responses of "you just have to learn it's internal architecture," it should be obvious what the problem is. The problem is not just being able to undo a mistake (though that's certa…

I feel that I only understand git because I’m forced to use it for years, but the experience could have been a lot less painful. I use a GUI for sure. Do people really diff and resolve big conflicts at a command line? I never figured out how.

  git mergetool
or

  git checkout --ours/theirs && git add .

Re: Git undo: We can do better

#244

I'm sorry, but how many bits of git's UI do we have to force users to manually replace before we realize that the entire problem is git's UI? Between the tone deaf responses here about "using a GUI client is the problem," to the tone deaf responses of "you just have to learn it's internal architecture," it should be obvious what the problem is. The problem is not just being able to undo a mistake (though that's certa…

Admittedly I did spend like a combined hour troubleshooting git over the last two months.

But git saved me an immeasurable amount of hours in return. I was asked what I worked on some specific week back in may -- git saved me. I had to look up what performance my program had before a specific change -- git saved me. I had to try stuff out without messing up my codebase -- git saved me.

True, I invested quite a few hours and I still do, but I think the investment pays itself off. I'll never ever do a project without git.

Re: Git undo: We can do better

#245
post #78

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. Most people don't know how the Internet works and yet it's widely used. You don't need to understand the inner workings of git. You just need to know some commands and some basic concepts.

The problem is not knowing git internal can very easily backfire by deleting data, rewriting history, etc

Re: Git undo: We can do better

#246
It's almost impossible to really lose anything once it's committed to git. Just look at the efforts it takes to really remove accidentally committed secrets.

The hard part is understanding how to get a reference to the thing you want to get back, how to restore it to its proper place in the history, or at least to a reasonable place, and how, if it's been pushed to a shared repo, for other developers to get their local clone properly sync'd up without their local work getting shoved off into some hard-to-reach reference.

Re: Git undo: We can do better

#247

Earlier quoted context omitted.

The problem is just that collaborative text editing between multiple users simultaneously is hard. It's a human problem and git attempts to be a technical solution but the abstraction fails at the edge cases. Regardless, what's so bad about deleting the repo and pulling from remote if you can't figure out why you hosed it? It's not like it costs you anything to do `rm ... && git clone ...`. And it's not like this hap…

I agree that collaborative text editing between multiple users simultaneously is hard. That doesn't mean that Git couldn't have a much better UI for this problem than it does. And while I agree that Git seems to have mostly won over SVN and Hg, it doesn't follow that it's because of its UI. (For example, I think that a lot of Git's success actually comes from the UI of GitHub, not Git itself, but I don't have evidenc…

This is the real interesting problem. Even simple subtle decisions like "should this list be kept sorted, or have new things added to the end" determine under what conditions you will hit a new conflict and when you won't. List of enums, add to the end, and if 2 branches grab the next enum value then you'll see a conflict. List of lets say URL prefixes keep in order, then most randomly added URL prefixes will not collide or conflict, only conflicting if you get 2 things trying to operate on the same prefix.

Re: Git undo: We can do better

#248

Earlier quoted context omitted.

> And if I push without first pulling I think I know git well, but you got me confused. I've never heard of pushes causing merges. Surely you are talking about pulls, right?

Maybe somebody who has a habit of using --force when pushing. A major downside of rebase-centric workflows is that it teaches you to ignore the safety rails when pushing, or when deleting branches.

`--force-with-lease` would fix this problem (it needs an alias). Also, `--force` wouldn't cause a merge commit; it would overwrite the remote changes.

The only theory that makes sense is that this person doesn't know how to `pull --rebase`, but the order of `push` vs `pull` wouldn't change the presence of merge commits, so I'm still confused.

Re: Git undo: We can do better

#249

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…

Are you using Git via GUI(s)? Between my colleagues, there is a strong correlation between using a GUI, and messing up the repository. I agree that Git's UX is pretty bad (checkout overloading; overlapping between checkout and reset; push overloading... yikes!), however, I believe that in contexts where using Git is a constraint, stop using GUIs is the best strategy one can apply to improve the understanding.

Funnily, I use a GUI almost exclusively to resolve mess-ups: Ungit is a great tool to understand the current state of the repository and fix it.
Post reply on HN