The greatest challenge, and most interesting thing about software development is the amount of knowledge there is. With every new skill I try and develop I find vast network of new knowledge pathways that I suddenly find myself wanting to pursue.
When I started learning to program, I learned about version control systems. It made a lot of sense and learning enough to get started was not too difficult at all. But, after a short while, I learned that what I knew was akin to saying you’re a New Yorker, when really you’ve only commuted back and forth to work, ate at all the ‘famous’ places listed in TimeOut or in movies, and rented an overpriced “luxury” no-fee apartment whose rent will price you out in 2 years, forcing you to do the search all over again, or perhaps, you’ve jumped into that empty subway car during rush hour, only to realize after the doors close, that you’ve made a terrible mistake! 🤢
The extent of my Git knowledge
The first thing I learned about Git, Github and version control, was copying a repo link and using ‘git clone’ to make a copy on my local machine. After making edits, I would ‘git add .’ and then ‘git push’. That was literally it. Not much.
It helped a lot to not be overwhelmed with having to learn everything about Git at once, because there were so many other things I had to also learn-Ruby, Sinatra, database schema and SQL commands, basic logic and syntax, then Javascript, React and a bit of Redux. If I also had to learn Git front to back, and logically, everything else top to bottom, it would have been too much for a person like me.
Perfectionism and trying to understand concepts and skills completely is my weakness, it prevents me from moving on to all the adjacent knowledge sets I need to know to be able to have a high level overview of a subject, before diving into specifics.
Fast forward a few months, I’m finished with the bootcamp program and have returned to volunteering time at the Fedora Project’s NeuroFedora SIG (learn more about FOSS) and run across a repository with multiple branches, in which I must make specific changes to particular branches. And, I’m asked by my patient and helpful co-contributor if I checked my ‘git log’ or if I have a ‘git log’ alias. Of course I said:
Then he asked me to add these aliases to my ~/.gitconfig and run them:
[alias]
lg = !"git lg1"
lg1 = !"git lg1-specific --all"
lg2 = !"git lg2-specific --all"
lg3 = !"git lg3-specific --all"
lg1-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'
lg2-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(auto)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'
lg3-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan)(committed: %cD)%C(reset) %C(auto)%d%C(reset)%n'' %C(white)%s%C(reset)%n'' %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)'
What is a .gitconfig?
Now, I know a ‘.’ (dot) file is a hidden file in a Unix/Linux filesystem, usually some kind of configuration file. But, what is a .gitconfig?
Apparently, this is the hidden, configuration file in my home directory (~) that contains the configuration values for my Git command. It contains some basic things like my github username, email address and also points to my .gitignore_global file.
What is a .gitignore_global?
It’s something that looks like this and has a list of file extensions that will be ignored when you use git (eg. git push). You can also ignore directories or whole repositories [blog post]. This is especially useful for things like API keys, Ruby secrets and other files you don’t want shared with the public. It’s becoming a real problem with unwary developers pushing their secrets and personal API keys into public view [case with Starbucks API, Amazon AWS leak, Scotiabank leak].
Apparently the .gitconfig can contain other things, like aliases. So, instead of typing “git commit” I can alias commit to “ci” and type “git ci”. I can also turn on and off colors and set different options that will make my Version Control experience that much better.
Phil Haack gives some great aliases and examples of their uses on his blog.
So, what does that ‘lg’ alias from earlier actually do? Well here is a video of a regular git log, vs the aliases:
Basically it more clearly shows the branches of the repository and the commits and how they relate to one another. Very useful when working on a project with multiple contributors on multiple branches.
If you’d like to see a sample of a .gitconfig, here’s my current one:
I don’t use all the aliases, but I’m currently writing up a git cheatsheet for myself and in the process I’m learning more commands. Most importantly I’m testing them in the the shell/console to see them actually at work.
Learning What Git Commands Do
I wanted to add this separate section to share these two links that I’ve discovered through the Flatiron School Slack channels:
- GitExplorer
Drop down menu (choose your own adventure style) way of discovering how to type in the commands you need to do something with Git.
2. ExplainShell
Explore not just Git, but other Shell/Console commands and have them broken down into pieces so you know what each switch and pipe is doing.
A Moment of Reflection
Ill end this week with two brief, more personal, thoughts. Last Thursday night, during an after dinner walk, I was thinking about my meandering work life and history and how it has always felt like I’ve been searching for some meaning in my life through work.
I put it together like this:
There is no more enjoyable adventure than to build and create together, no greater satisfaction then looking back and seeing what you have built and experienced together.
Part of my Flatiron School was discovering what fulfills me as a person. I believe part of it is helping others. And finding mutual beneficial ways to learn, grow and succeed with and through each other. Sometimes not, but I find fulfillment regardless.
The intersection of friendship, community, creativity and utility of purpose — its a unique place that skills in software development offer at this time and place. A way to make money, but also work on great projects, build your ideas and share them with the world.
So, my friends, let’s go out and build something together and look back on it in years and say “If this isn’t nice, I don’t know what is.”