Branching, making commits, and creating pull requests come easy, but beyond that, I know utterly nothing about it.
Branching, making commits, and creating pull requests come easy, but beyond that, I know utterly nothing about it.
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?
2) I try to stay out of holy wars. Use the right tool for the job, I say, and sometimes that could even be Emacs. ;) I do talk about a few of the more common options for branching in teams (mostly focused on the small teams we tend to have here in university). And I talk about their pros and cons. But I stop short of declaring one the winner since the best option depends on the circumstances. IMHO.
3) I've seen repos with big functions and small functions, so I don't think it's a Git thing. Students tend to write functions that do too much and are too large, but it's certainly possible to break things down into pieces that are prohibitively tiny. Overall this seems more of a software engineering design choice than anything Git-related.
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