Branching for dummies?
ELI5: Git Branches
Let's say you have written a social networking website. You write a bunch of code, then your site goes live on January 1. We will call this version 1.0. After the site is up and running you want to write some new features, and plan to release them on April 1.
Uh oh. Mid February you get a report of a serious bug in your program. You need to fix that bug now. You could add the bug fix to all the code you've written since January, but that has some problems. All that code you've written since January is not ready to release. It needs more work and won't be ready until April. If you code your bug fix on top of all the new code, you either have to release the unfinished code, or wait until April. Neither of those options work.
Instead, what you do is you go back in your repository to version 1.0. You code your fixes on top of that "older" version, and call this version 1.1. You then release version 1.1 and things are good.
However, there's one small problem. The history of your project now looks like this.
v1.0 new code for Apr
| |
o--o--o--o--o--o--o--o--o--o
\
o
|
v1.1 (bug fix)The history of your project is no longer linear. It has two branches. If another serious bug comes up again, you can code it on top of version 1.1 and release that.
v1.0 new code for Apr
| |
o--o--o--o--o--o--o--o--o--o
\
o--o
| |
| v1.2
v1.1Eventually, when all the new code will be ready for the April release. But there's one last problem to solve. The bug fixes you put into production (v1.1, v1.2) are not part of the new code for April release. To solve this, you merge the two branches into a single branch.
v1.0 v2.0
| |
o--o--o--o--o--o--o--o--o--o--o
\ /
o--o----------------'
| |
| v1.2
v1.1Now you have a version 2.0 that contains all the new features for April, and the bug fixes that you had to release in February.
More on reddit.comELI5: What really is Git branches, how to effectively use them, and whether or not we followed good git workflow.
Advice for Git branching strategy?
Videos
I need someone to explain this to me because I feel like an idiot and I'm getting frustrated. This is at least the third time I've tried to get even a rudimentary understanding of git and it just doesn't take.
I'm walking through this guide because based on the title it should be my speed: https://medium.com/@rukeeojigbo/git-basics-an-idiots-guide-99445a56bd65
Switching between branches sounds simple enough. So I create FirstBranch and edit a text file in it. Cool, git status lets me know there are new changes it detected. Well I don't want to commit anything yet, I want to continue playing around with branches. So I create SecondBranch and check the text file. The text file has the same content that it did on FirstBranch. I guess that makes sense since we were sitting in FirstBranch when we created SecondBranch. I edit the text file with some blurb about it being in SecondBranch. Branches are basically just folders I can swap between right, so let's hop back over to FirstBranch and see that other version of the text file that doesn't have any references to SecondBranch. Oh it does have references to SecondBranch, which means this doesn't work at all the way I thought it did. Now I'm just confused and frustrated.
I need an idiot's guide to git and I'm beginning to think one doesn't exist because it's simply too complex of a tool for me and I'm going to just go back to manually making dated copies of the project folder every time I need to snapshot progress.