My superhero mentor attempts to teach me the correct pronunciation of the "I" in git.
That's the least of my challenges.
The great challenge is to explain Git to my mom, who has taken an interest in my Elixir journey, hoping that his son will finally have a real job she can talk to her neighbors about without too much struggle.
If you can explain it to mom, you understand it yourself.
Who in his right mind could understand a creature that has branches and is not a tree. Has forks and is not cutlery. Pushes and pulls and is not a girlfriend.
So far I understand the concept of repository pretty well: that is where my code reposes.
AKA: "Mom, imagine a place somewhere where all the code I write is stored and organized"
-- All of your code is in that repository?
-- Not all. I create one repository per project, like you have a closet for summer clothes, another one for winter clothes, another one for clothes to charity
-- Gotcha (this gives me hope)
-- Wait for it. I need to initialize a repository when I am working with it. The instruction or command for this is git init
, like you are in-it.
-- Like when I open the summer clothes closet. I have initialized the Summer Clothes Repository and I am in-it.
Mom. Senior Engineer. Her LinkedIn page is being updated as I write these lines.
I am making progress. I explain that she doesn't just throw all clothes in there (that'd be my style). She has stages when working with the Summer Clothes repository.
-- Imagine you go shopping and buy a nice summer shirt. Is that already in the Summer Clothes Repository?
-- Nope. But it is on the way.
-- That is an untracked change in the closet. As far as the closet is concerned, it doesn't exist yet, but you are working on it.
-- Go on
-- Mom, if you had a terminal window in your heart and I keyed git status
you would tell me about that summer shirt. You would not tell me about what has not changed in the closet, but about what has changed, could change, or is about to change.
And this is where Git starts to resemble Jack Nicholson in As Good As It Gets.
The beast has a bit of an OCD attitude to change. It likes procedures and patterns to the point of needing therapy. But... thank God, because if it was up to me, that Summer Clothes Closet would soon resemble an LSD trip, which could be fun, but would not facilitate a peaceful (nor sustainable) domestic experience.
-- Mom, you first DECIDE the shirt belongs there, and then you ACTUALLY put it there
-- I go through those processes organically. You need to break it down into each step, because computers are silly creatures that need short, understandeable commands... very much like you.
-- That's why I may be suited for this after all. Back to business: when you decide the shirt belongs in the closet you STAGE it with git add <shirt>
. When you put it in the closet you COMMIT it, with git commit
.
-- Yes, I could decide that I do not like that summer shirt after all, or gift it, or lose it... there are reasons why it wouldn't make it to the closet.
-- That is the untracked change
Mom starts rethinking her entire domestic ethos, and wonders if parenting and homemaking had been easier had she explained domestic duties in this fashion to the men in the household.
On second thoughts... No, it wouldn't. I can hear the talk at home: "are those dishes untracked, staged, or committed to the dishwasher?"
-- "Some are staged, and some committed. Any untracked dishes around the house?"_
-- "Look in your dad's office. He is always leaving cups of coffee untracked. I always end up committing them for him."
-- "He likes to think as them as staged in his mind. Like he'll commit them later."
-- "Well, if he never commits them to the dishwasher repository, they are as good as untracked to me. They remain around the house forever."
(We may have commitment issues...)
I break it to mom that it is good practice to add a message when we commit, because a bit of fanfare never hurt anyone. Mom would shout "Dishwasher ON!" or "Summer Clothes Done!", which I would do with git commit -m "Dishwasher On!"
. Now we know. The repository knows. Even Jack Nicholson is satisfied. Everything is tracked, and clear, despite the rest of us developing OCD as a result of all of this.
Branching out
My challenge here is to explain branches to mom. She lives in reality, where time cannot be turned around, and where changes we made cannot, for the most part, be undone.
Most ex-girlfriends understand this... Some do not.
I ask her to imagine that everytime she commits something to the closet, or any other repository, Git takes an internal picture, makes a dot in the map, leaves a breadcrumb, holds onto that thought forever.
Imagine each commit as a step on the journey to the final Summer Clothes Closet, and Git taking a picture of how everything was at the exact time of each step.
Controlling doesn't even begin to define Git. You do not enjoy a git-like mind in your loved ones. Alas, I start to learn that the more git-OCD you develop, the better your life as a coder. There are books and online courses on how to develop this pathology in a systematic fashion. Proceed with care.
Exhibit A: https://git-scm.com/book/en/v2
Back to the main topic:
Git gives you the option to go back and forth through all the commits, check things out, revert back to a happier time. One can, literally, step back. One can ask git about each step of the way to Summer Closet Perfection wtih git log
.
Each step is kept in something like an inner picture that one can work with independently. And one can create those steps at will. Git calls them a branch.
-- Why a branch?
-- No idea, mom. I guess it is because it departs from something original and foundational, like the trunk of a tree. The point is that you can look at all the steps on the way and work with them. You can also create your own version of the closet, without having to touch the original, main closet
-- Why would I do that?
-- To test things out without messing the real closet badly
-- So one version per commit, which you see with the git log
thingy, and also the option to create my own branches, which I do how?
-- git branch <branchname>
-- I imagine I will have to tell Git which branch I am working on.
-- Genius: git checkout <branchname>
indeed
-- So... Let's say I am cooking brunch, and each commit is each step on the way: I add pepper, I throw oil to the pan... I could totally create a new branch to safely experiment with the amount of salt that hits the sweet spot (git checkout -b salt-experiments
). Once I know the perfect amount of salt, I would commit that amount, go back to the main dish with absolute confidence. I guess I would have to tell Git to take the information from the salt-experiments branch into the main dish branch. I assume there will be something like a git merge
or git pull
Mom runs to her laptop to create her new blog "Branched Brunch", while I recover from her already intuiting git merge
.
Moms have superpowers. Have you noticed how they predict the weather better than AI machine learning models? I do not even know how to begin with merging and pulling. She just pushed me to the edge of my current understanding, and I fell into the abyss.
-- Son, is there any way that I could create branches for my friends, let them experiment with different aspects of the recipe, and then evaluate and merge only the very best to create the perfect one?
It's just too much. I cannot yet put all of this together: remote versions of dishes, amount of guacamole version control, permissions for not letting Susie add vodka to the omelette... but mom: she gits it. I am not sure I do.
I leave the conversation humbled and go back to studying. Surely I need to return to this conversation. Next time, better prepared to face my worthy contender.
For the time being, I'll share a true story about my mom. She once received a call from social services, enquiring about her wellbeing and needs. The lady on the phone asked her: "Do you use the new technologies in your daily life?". I had to giggle. She had just made a 25% profit in her Bitcoin and Ethereum wallet, and used the profit to blast through the car payments. Does she use the new technologies... She is a Cyborg.
git add .
git commit -m "Moms rock. Thanks for reading"
BigSpaces
Top comments (2)
Another great post! Great analogies! And what can I say about your mom, she is amazing!
Glad you liked it, Bill! Yup, she gets actually interested in my Elixir journey as well as all techie things I learn along the way. What can I say? I am blessed :)