Live data from Hacker News

Oh Shit, Git

ohshitgit.com

101–110 of 237 posts

Re: Oh Shit, Git

#101
post #30

Earlier quoted context omitted.

Depends. Sometimes it's easier to tear down everything and start from scratch.

Isn't this what a `git reset --hard` does?

That just resets to your last local commit. To sync back up to the remote, you need at least do a git reset origin/HEAD --hard (and capitalization matters, I don't know why).

But that doesn't work if you rewrote history in some way (I'm not sure why that's even possible). In that case your local git can get pretty messed up, some gui tools (IntelliJ) start to bug out and fail to diff properly, and it's easier to just start over.

After ten years of using git, I've more confused by it than ever. People here keep talking about mental models, but I've read a shit ton of docs on it and am still totally confused. Probably some of us just aren't smart enough lol.

Re: Oh Shit, Git

#102
post #31

Earlier quoted context omitted.

Depends. Sometimes it's easier to tear down everything and start from scratch.

I spend my life in git. I never ever had to just erase everything and clone again. I do not see a situation where it would be needed honestly.

It's needed when you're somebody who doesn't want to spend their life in git and just want to undo a mistake.

Re: Oh Shit, Git

#103
post #70

Earlier quoted context omitted.

> for knowingly setting up ill-conceived software to go viral I doubt that was the intention. Linux just needed a versioning system tailored to its needs, and that's exactly what Git is. Can't blame its creators that other people used it for scenarios it wasn't built for.

Right, you are the cop-out I am complaining about. Linus is the premier figurehead of the premier open-source project. When a build tool he made for that project goes viral it isn't an accident. If it was anybody else's pet versioning control system would we even be talking about it?

What you're saying is that anything Linus does, for whatever purpose, should be designed to cover a wide variety of use cases and please a large number of people, even if he's just writing something for himself. I think that's an unrealistic expectation.

Re: Oh Shit, Git

#104
post #76
post #45

Earlier quoted context omitted.

Git's UI/UX is one of the worst engineering sins to be committed in the last two decades, and this website shows why. Literally nothing about git is intuitive and the "underlying model" is entirely ad-hoc. Instead of celebrating how Linus built git in only a few days he should be castigated for knowingly setting up ill-conceived software to go viral.

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.

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

Re: Oh Shit, Git

#105
post #79
post #2

If you stick to master-only development things like commiting to the wrong branch can't happen: https://medium.com/@mattia.battiston/why-i-love-trunk-based-...

If you cut off your limbs, you can’t get gangrene either.

But you end up with one really well developed and tested head.

Re: Oh Shit, Git

#106
post #45
post #4

Git is a reminder why even the best minds in software development sometimes really should talk to UX/UI people.

Git's UI/UX is one of the worst engineering sins to be committed in the last two decades, and this website shows why. Literally nothing about git is intuitive and the "underlying model" is entirely ad-hoc. Instead of celebrating how Linus built git in only a few days he should be castigated for knowingly setting up ill-conceived software to go viral.

I think the underlying model is fantastic, but the names for operations, and how they are grouped, are somewhat ad hoc.

The idea of a directed graph of file system snapshots is pretty intuitive. Add in branches as pointers to locations in that graph. This is a fantastic model for source control.

However the operations that stage a potential update to the graph of snapshots is prettt confusing. The "index" is a terrible name that is overloaded with so many other non-git meanings, non of which really map to git usage.

That, and all the rest of the names are pretty hard to understand. Particularly reset, whose documentation is inscrutable without translation from git-speak into technical language, or at least a dictionary of what all those words that are used actually mean. And since reset is such a useful tool and has about eleventy different functions, it all becomes impossible to learn from the docs on your own.

Re: Oh Shit, Git

#107
post #12

The best part is the header alert - if you don’t like the profanity, check out dangitgit.com!

I liked how the Japanese translation of the page retains the two versions, but the language difference made the variants pretty much pointless, because there are hardly any "profane" words in Japanese that are offensive enough to warrant censoring by their utterance alone. (There do exist a group of offensive-enough words that relate to class/race discrimination, but no equivalent of a censor-worthy 'shit' nor 'fuck'.) The 2 Japanese translations are merely written as one mildly colloquial version vs another very-slightly-less-colloquial version.

Re: Oh Shit, Git

#108
I find people are religious about being git cli purists and only interacting with it in this black box (the terminal). On top of that a lot of people stop learning git after add commit push pull branch and merge so concepts like rebasing and cherry picking are scary. In this day and age we have state of the art GUI tools that change the game and allow git users to see and interact with the state of a git repository in real time. It's a great way to demystify things like rebasing and interactive rebasing because they show you what's happening in a modern UI designed specifically for git. I often suggest git CLI purists to get something like git kraken and just use it as a visual dashboard. Watch what happens when you run git commands. You can see everyone else's remote branches and have a much better idea of what's going on than you can without it. I've worked on teams that just didn't rebase at all and I think people are oblivious to the mess they make on branches with their chaotic merge strategies. These days, I tend to envision the state of the branch that I want and make that happen. It's so easy to create a new branch before I do anything that if I think something might go south, I just hard reset to my previous state (a branch I created right before the operation) Gitkraken also has an undo button that handles all sorts of scenarios and I rarely click it without getting exactly what I expected.

Re: Oh Shit, Git

#109
post #4

Git is a reminder why even the best minds in software development sometimes really should talk to UX/UI people.

It's never too late. I think gitkraken fixed this problem

Re: Oh Shit, Git

#110
post #30

Earlier quoted context omitted.

Isn't this what a `git reset --hard` does?

That just resets to your last local commit. To sync back up to the remote, you need at least do a git reset origin/HEAD --hard (and capitalization matters, I don't know why). But that doesn't work if you rewrote history in some way (I'm not sure why that's even possible). In that case your local git can get pretty messed up, some gui tools (IntelliJ) start to bug out and fail to diff properly, and it's easier to just…

Not sure what origin/HEAD is supposed to point to. HEAD is a ref that points to the tip of the current branch. It's not going to be available for remotes (it just doesn't make sense).

To reset the current branch, you need to do two things:

  $ git fetch
to fetch commits from the default remote and point remote branches accordingly, and

  $ git reset --hard origin/master
to reset HEAD to the remote branch. Substitute master for any other remote branch if you wish.

That's it. I don't know if this is more difficult than re-cloning from scratch (especially if you're doing frontend and then have to reinstall node_modules and such…)

Post reply on HN