Live data from Hacker News

Oh Shit, Git

ohshitgit.com

201–210 of 237 posts

Re: Oh Shit, Git

#201
post #194

Git is just a tool, or better, a toolset for software development. Saying that it is too hard to me is a huge red flag. It means you do not want to spend the time, or the effort, to learn it. It's like a mechanic saying that a wrench is too complex.

I think your analogy is a bit reductionist. The difference between git and a wrench is that the wrench presents almost all of its intended uses. I can quite confidently say that most people will understand it within a few minutes.

Git is like CSS in the sense that for experienced users will sometimes forget the difficult learning process they went through, e.g. "oh use margin auto to centre the div"

I've been there, finding git too hard and giving up, but I've came back to it and eventually got past that uncomfortable learning bump.

Re: Oh Shit, Git

#203
post #158

Earlier quoted context omitted.

Good modern software always offers an undo option. Where is "git undo"?

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.

Nobody said that rm was perfect ;)

Re: Oh Shit, Git

#204

Earlier quoted context omitted.

Interesting take. If anyone care to actually learn how git works when rebasing, then it becomes much simpler. I always rebase and in 10 years of professional use, never once had a problem with it. That doesn’t mean other people don’t.

But you're still going to have a worse history than you would have by just letting git merge Do The Right Thing.

Do you care to explain? How can you have a worst history when the `main` / `develop` branch have a linear history? I rather have a linear history where git bisect is trivial to use then a mess of merges and a hard to follow history.

Re: Oh Shit, Git

#205

Earlier quoted context omitted.

Can you substantiate your opinion? It's open source, so why hasn't an alternate interface taken over?

Because standardization matters and the first thing to become the standard is extremely difficult to unseat.

But some of types of things have in fact changed, sometimes for seemingly trivial reasons.

For example, the master/main branch shift. Everything broke when that change was made, but it happened and it wasn't a big deal.

I'm not seeing the difficulty here. It seems that a more reasonable interpretation is that git has the type of interface that is hard to learn, but intuitive once learned.

Re: Oh Shit, Git

#206
post #170

Earlier quoted context omitted.

> Do I need to know how a gearbox works to drive stick shift? No, but it helps. If I treat my car's powertrain as a black box then it won't be intuitive that: * I shouldn't slip the clutch to hold my car on an incline. * Blipping the throttle gives me smoother downshifts. * Double clutching lets me shift from 2nd to 1st while rolling. * I can use the engine to slow my descent on longer hills and avoid brake fade * I…

It may not have sounded like it but I'm actually going to agree with some of this. We might be on a different part of the gradient so to speak. Maybe you can find a good analogy but at least from my point of view the gearbox analogy is falling short now and we'd need a different one or look at git commands one by one :) Like you say, you can just remember those things. In fact 4 out of those 6 were taught in driving…

You're absolutely right, there are about a million and one rabbit holes you can go down if you _really_ want to understand the tools you use but in the vast majority of those cases you're better off relying on a higher level abstraction.

The interesting part to me of your analogy is that it can demonstrate how having an understanding of what's going on under your layer of abstraction allows you to generalise.

To wring the last bit of life out of the gearbox analogy: if you tell a mechanically inclined driver that blipping the throttle will make their downshifts smoother, they'd hopefully understand how rev matching can be generalised to upshifts too. If you tell a "black box" driver then they probably wouldn't be able to do the same. Of course, the analogy falls apart a bit because understanding rev-matched upshifts isn't particularly useful :)

I've forgotten most of the "advanced" git knowledge I ever learned but I get a lot of value out of the (admittedly not very advanced) understanding that, as you said, commits are a DAG and that branches are just named pointers to nodes on the DAG. That understanding lets me generalise to, for example, backing up a branch (with git branch/tag) before doing a tricky rebase so I can restore it (with git reset --hard) if I need to undo.

I agree that exploring every rabbit hole to the end isn't beneficial - understanding the DAG is typically the only "advanced" git knowledge I need and I've only very rarely had to peel back more layers. I think this:

> It's good to know they exist and be able to dig in when needed/wanted.

is a good way of putting it. My ideal low-level understanding of most tools is knowing just enough that I know what to search for if I ever need to go deeper.

Re: Oh Shit, Git

#207
post #191

Earlier quoted context omitted.

Interesting take. If anyone care to actually learn how git works when rebasing, then it becomes much simpler. I always rebase and in 10 years of professional use, never once had a problem with it. That doesn’t mean other people don’t.

> If anyone care to actually learn how git works when rebasing, then it becomes much simpler. That's a very arbitrarily vague answer. It's very easy to hand-wave the misuse of a tool just by saying "you don't know it well enough". It's much harder to admit that maybe the tool is just difficult to use in the first place.

I have similar experience as the person you are answering to. Unlike them, I got into rebasing only recently. It isn't really a hand-wave of saying 'you don't know it well enough'. This paradox is caused by a quirk in git's design. Git uses a hybrid model for dealing with versions. It uses snapshots for storing them, as well as for operations like fetch, clone, etc. But that mental model causes a lot of confusion for operations like merges, pulls etc. Git uses the diff-patch model for those operations. Even weirder, much of git is actually designed to use the diff-patch model. The first time I ever got a grip on those operations was when I did rebasing. I found git much easier to understand when I could attribute each operation to the model git uses behind the scenes.

> It's much harder to admit that maybe the tool is just difficult to use in the first place.

That is unfortunately true. Git feels like a tool with several parts that were bolted on to solve problems its users (developers) faced. I didn't have that same difficulty with mercurial. I get this feeling that a pure patch based tool like pijul would match their workflow well and still be easy to learn.

Re: Oh Shit, Git

#208
post #177

Earlier quoted context omitted.

svn has made many improvements lately too, especially in conflict resolution. don't make the mistake of comparing "git now" vs "svn then".

Speaking about SVN, what about Bazaar? It has been described as distributed SVN. I really hated SVN, almost to to point of wanting to go back to CVS, so I didn't want anything that took any inspiration from it. But maybe, in reality, it is not that bad.

The funny thing about the "svn vs git" debate (if one could call it that), is that people always tend to focus on the whole "svn is centralised whereas git is not" bit as the main argument.

Yet, whenever I've worked on git with others, it's been on github (i.e. a centralised model). And I've worked in a decentralised way on svn on several occasions, simply by making my own local repositories and merging changes back to the parent repository when I'm done (which is effectively what git does too when working with remote repositories).

I feel that a lot of what ends up being 'bad' about svn really boils down to the fact that you need some good conventions to be honoured across the project in order to get things done (including using it as part of a decentralised workflow), but humans being humans take shortcuts and mess things up for everyone else. Which really means at the end of the day, the problem isn't the technology per se, but human relationships, manifesting as commit behaviours. Whereas git just imposes its highly opinionated model of doing things on you in order to ward off some of the more destructive human behaviours, which in a sense is good, but at the same time, it means that git can be too rigid, and svn effectively gets a bad rep for being potentially more flexible and scriptable. I've been in many situations where I had to get into an incredibly convoluted manual process to work around git's mental model to get it to work for me, when the equivalent in svn (for better or worse) would have been fairly straightforward.

(Disclaimer: This is just my personal experience from happily using both with no specific preference for one mental model over the other. If anything, I think I may probably prefer svn a bit more now. I'm probably completely wrong about all of it.)

Re: Oh Shit, Git

#209
post #137

Earlier quoted context omitted.

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.)

Of course, but Git keeps track of everything you undo, which at the meta level is something you can't easily undo ...

Maybe I misunderstood your question, what were you asking about above?

Re: Oh Shit, Git

#210
post #199
post #137

Earlier quoted context omitted.

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.)

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

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.

Post reply on HN