News for hackers. Stuff that matters.
Re:Git cherry-pick and revert use 3-way merge by hiAndrewQuinn on Friday November 10, 2023 @02:13PM (#38223154)
I could use a Git By Example course where we walk through increasingly gnarly gituations.
Re:Git cherry-pick and revert use 3-way merge by chx on Friday November 10, 2023 @02:29PM (#38223373)
The only git tutorial that worked for me is the exact opposite. It even warns you

> you can only really use Git if you understand how Git works. Merely memorizing which commands you should run at what times will work in the short run, but it’s only a matter of time before you get stuck or, worse, break something.

https://www.cduan.com/technical/git/

this tutorial was an absolute revelation for me. I can't recommend it strongly enough.

Ps: I also found git destroying my work via git reset to be really annoying so I built a safety net. https://gist.github.com/chx/85db0ebed1e02ab14b1a65b6024dea29

Re:Git cherry-pick and revert use 3-way merge by yencabulator on Friday November 10, 2023 @05:42PM (#38225557)
Re:Git cherry-pick and revert use 3-way merge by chx on Saturday November 11, 2023 @09:34AM (#38230607)
Not sure whether I count as a computer scientist, I only have a math teacher masters and half an information engineering degree, I dropped out.

Even knowing graph theory and understanding git I still don't have the shortest idea what https://eagain.net/articles/git-for-computer-scientists/git-... this even wants this to be.

Re:Git cherry-pick and revert use 3-way merge by yencabulator on Saturday November 11, 2023 @11:12AM (#38231544)
A tree can point to other trees, making them subdirectories. A tree can point to blobs, making them files in that directory. File name, mode and such metadata is a property of the edge, and blobs themselves are nameless containers of bytes.
Re:Git cherry-pick and revert use 3-way merge by Quekid5 on Friday November 10, 2023 @07:06PM (#38226209)
This is so true. Understand what git is truly about, namely a particular kind of Graph and how to apply changes across those.
Re:Git cherry-pick and revert use 3-way merge by seba_dos1 on Saturday November 11, 2023 @04:10AM (#38228683)
Exactly. Learning by examples is the worst way to learn git - which sucks for people who learn best by examples, but that's how it is. You often hear people complaining about git's UX - and I agree that it could be much better, though I'd say its main sin is that it almost actively tries to confuse you into developing wrong mental models on how it works (somewhat ironically, it often does it to provide better UX for those who already understand it).

A very obvious example of that would be right there in `git show`, or the equivalent parts of GitHub's and GitLab's UIs. A command that shows you the content of a commit, right? Well, right - it does show you the author, date, commit message... but then it also shows a diff.

So, being a beginner who learns by examples, you say - I get it! A commit is a patch! It gets me from one state of the repo to another!

Except you couldn't be more wrong. `git show` automatically calculated a difference between the requested commit and its parent to present it to you, but didn't bother to tell you that. Of course, it makes perfect sense - it wouldn't be very useful to show a complete state of the files under the commit in question, it's much more useful to show a diff against its parent. However, it doesn't even tell you which commit the diff was calculated against, it's completely hidden by default. How are you supposed to develop a proper mental model of total basics as "what is a commit" if it hides such essential clues from you?

Answer: you need to read up on the theory. There's no way around it, at least not now.

Re:Git cherry-pick and revert use 3-way merge by bloopernova on Friday November 10, 2023 @02:20PM (#38223253)
https://www.leshenko.net/p/ugit/#

There's another that was useful, I'll dig it out and update this comment.

This one helped me a lot: https://alexwlchan.net/a-plumbers-guide-to-git/

Re:Git cherry-pick and revert use 3-way merge by Tyr42 on Friday November 10, 2023 @02:32PM (#38223418)
Also check out the New Old Thing for more gnarly git examples.

Raymond Chen is excellent.

Re:Git cherry-pick and revert use 3-way merge by Quekid5 on Friday November 10, 2023 @07:07PM (#38226214)
Raymond Chen's blog is a gift to this world.
Re:Git cherry-pick and revert use 3-way merge by conor- on Monday November 13, 2023 @02:48PM (#38254421)
I think this possibly fills what you're looking for.

https://learngitbranching.js.org/