Git finally made sense!

Patricia Rhoda Nekesa
5 min readNov 16, 2020

--

This is my second year in the programming world which has been littered with sporadic moments of Andela, freecodecamp, YouTube stars , CodeQueen and the latest: The Catalyst program run by Refactory.

The journey so far has not been an easy one but I digress, this post is dedicated to git and her wisdom. I decided to write this article at this point because I want to capture the innocence of new found knowledge, unadulterated by the complexities that I will learn soon enough concerning software development and version control. Before I forget “folders” and naturally call them “directories”. This is for you, my friend that has just heard of git and why you should make her your best friend,confidant and lover on your software engineering journey.

Git is a version control software; that is the cool way of saying that it is a tool that helps you track the growth of your software project from idea to fully grown adult with midlife crisis problems. You choose when you want git to help you track your baby’s progress but I advise that you choose git as your Doctor as soon as you miss your period. A better analogy is looking at git as your code diary. It’s where you record the work you have done and all the boys that broke your code heart with their terrible language…

Anyway, git has a couple of friends that make her work visible on the internet and depending on the teacher’s preference, you will work with Github, Bitbucket, Gitlab among others. So far, I have only interacted with Github and I find it okay(65%) based on human instinct alone and the interfaces I have used. You should have an account with one of these hosting services for easier tracking of code and code sharing especially if you intend to work in teams and submit your code to your code facilitators and also for future reference. If not interested, it’s all good since git can exist independently on your laptop. Download and install it on your computer.

Now for the GitHub connection, since we know the world is unpredictable and the dog can actually eat your homework, your computer can crush, a pesky child or adult can delete your folders and ask for forgiveness but the damage is horrendous and forgiveness may come but forgetting never happened we need to backup important things ,so create your free GitHub account immediately and remember your username and email used. After this, we connect our cloud account to our local computer. In your terminal run the commands git config --global user.name "Your name here" and git config --global user.email "your_email@example.com".

That’s it, the rest of connection magic will happen automatically. The next thing we need to do is create a repository on github. This is a fancy way of saying a folder for your project. You will be taken through a series of steps that will help you create one and then lead you to a page that gives you a link to the new creation. Copy the HTTPS one.

Go to your terminal and type the command git remote add origin “the copied URL address”. To check the connection, type the command “git remote -v”. Now that we have connected local git to internet git. We can start coding.While coding, you should ensure to work smart and therefore work on projects in particular folders say a folder named according to the project name for example “Kesaz project”, “Food App” etc.

After installing git, make sure to invite her to your coding party with the command — git init in your terminal. Still struggling with understanding the terminal? just know, this is the heart of your computer, it is where you go when you need to have a one on one with the big guy, and you speak “ real computer” in there, there is no auto correct, if you include space where it shouldn’t be, the masters there will stare at you and run their mouth in so many lines to tell they do not understand a thing your saying! Point being, make sure to write the command as is.

After inviting git, she is now at your party, she’s taking notes, analyzing any changes in dance moves, tracking growth of your code and smiling at your knowledge and storing it in her database. To understand what she has done, you need to run the command “git status” and she will tell what you just did but to permanently store her information, you must add the files to her store using the command “git add . ”(The full stop is very very important!)then add a message to it, She will not store your information if you do not message her so be kind, be wise, your message should be informative to both you and her, tell her and yourself what you have done so far or added to your code, this is your dear diary moment using the command git commit -m “your message here” for example , git commit -m “Started on the smoothies section”. These messages will help you track your progress meaningfully and also help you identify instances when the code was working perfectly and then it wasn't, trust me, it happens. Apparently computers do have brain freezes.

To go through all your “dear dairy” moments, all you have to run is the command “git log” and voila!, all your messages, when they were created, what you did will be on your screen.

Remember when we connected git and GitHub, now we should push our work to the internet. Run the command “git push -u origin master” and watch the magic happen. If you go to your github repository now, you should be able to see the work you have pushed. This will also include your comments created during the “git commit -m” moments.

So we now know,the basic git commands , the git init, git status, git add . , git commit -m “.”, git log. git push , git remote add .

Now for the grand maestros, Imagine an instance where you are 4 individuals working on the same project, you wouldn’t want John, Jane , Julius and Mary all working on the same exact page , that means if the page was blue today because John loves blue then tomorrow Jane feeling bright and sunny will make it yellow! All the while Julius believes it should be black because it shows power and who does not like power meanwhile Mary thinks lavender is the best color in the world and plans on changing it soon. In summary, humanity’s spontaneity is catered for in git and we shall be looking at it in my next article.

I hope I was able to teach you a few basics in basic language. It gets better, trust me, because, practice, my friend, makes perfect.

--

--