←back to thread

1062 points mixto | 1 comments | | HN request time: 0s | source
Show context
boneitis ◴[] No.42942112[source]
I'm really interested and really hoping this is something I can sink my teeth into. I've always had frustrating experiences with trying to wrap my head around git and have to regularly use it at my job.

Branching, making commits, and creating pull requests come easy, but beyond that, I know utterly nothing about it.

replies(2): >>42942475 #>>42942759 #
beej71 ◴[] No.42942759[source]
If you do check it out and there are parts that are confusing, I'd love to hear about it.
replies(1): >>42943275 #
at_a_remove ◴[] No.42943275[source]
This is partially a question and the rest is shameful confession: I had haltingly used cvs as a solo programmer, and when I was suddenly no longer a solo programmer and had to use git, everything went haywire.

I am an Old and we never were taught anything about coding with other people who were also working on the same project. I have had many successful projects but never with another person.

With that as a background, does your guide cover things like:

1) Merging. I was told that merging happens "automagically" and I cannot, for the life of me, understand how a computer program manages to just ... blend two functions or whatever and it "works." Does your guide make sense of this?

2) Apparently there are holy wars (see also vi versus emacs) about the One True Way to ... decide on branches and whatnot. Are there pros and cons laid out anywhere?

3) Everything seems broken down into teensy tiny functions when I look at someone's git repository, just skillions of files all over the place. Is this a git thing, a code repository thing, or simply that, in order for multiple people to work on the same project, everything must be atomized and then reassembled later? What's your opinion?

replies(3): >>42944400 #>>42944723 #>>42948668 #
1. lucasoshiro ◴[] No.42948668[source]
> 1) Merging.

It's really simple, much more than what we think at first. I explained it myself here, in section "three-way merge": https://lucasoshiro.github.io/posts-en/2022-03-12-merge-subm...

There are plenty of other explanations out there if mine isn't enough clear for you, just google "Three-way merge".

> blend two functions or whatever and it "works."

It's purely based on find changes and it doesn't check the syntax. If the commits has been merge correctly is responsibility of the programmer.

Look at this valid Python code:

if a == 1:

    foo()

    bar()
If a branch deletes foo() and other branch deletes bar(), it will merge to this invalid Python code:

if a == 1:

In Python we can't just leave empty blocks, like C or Java. In Python we would need to use "pass":

if a == 1: pass

So yeah, there are cases that merge doesn't work because Git operates over data, no matters too much what information they hold