Understanding Git Terminologies : The Fun Way.😎
By: Hafsah Emekoma
Tags: Web Development, Github, Technology, Beginners Guide, Git

Git logo from the official git documentation website.

There are hundreds of Git tutorials out there; each explaining various aspects of Git, and how to use them. Why then am I creating another one?

The answer to this is that I simply want to explain Git in a fun and easy to relate manner. This post does not promise to cover everything there is to know about git, else we would end up reading for a really long time.

Now that i have answered that question, let us dive into the wonderful world of Git.

What is Git?

Git is an amazing tool. Very amazing, I must say.

When I first started with Git, whenever I searched for “What is git?” The first answer i saw was always along the line of “Git is a Version Control System…”

Most times, I wanted a straightforward answer. “Yes, it is a Version Control System. I have seen it in the twenty other pages I checked, tell me what Git is already !”

So if you are like me, and you want to go straight to the git terminologies, sorry to disappoint you, but we will have to start with Git being a Version Control System (VCS).

Git is a Version Control System, the most commonly used version control system at the moment. Being a Version Control System means that it keeps track of all folders or files being monitored by it.

Git does not stop at just tracking your files, it also keeps track of:

What files were changed.

What changes were made.

Who made such changes.

When the changes were made.

When most people hear of Git, they think of software developers. This is not necessarily the case. Git can be used by anyone who wants to keep a track of their files as they work; can be a writer, a designer or someone who wants to track all the movies on their computer. Anyone at all.

Git also makes collaboration very easy, it allows multiple persons to share and work together on the same set of files without conflicting each other’s work. Cool right? Definitely!

To share and work with other people using Git, you will need access to a Git-based hosted service like Github, Bitbucket, and more. You can research on the one you would love to use.

Git is a software that you can access through your computer’s command line(terminal), or through Gitbash. I use Gitbash.

To get started with Git, you can read more about it in its documentation website which is linked below. 👇

Git — Installing Git

Now that we know what Git is, let’s talk about the various terminologies used in Git.

Some Git Terminologies We Should Know.

Git init : This is the command used to initialize git in a folder. In your terminal or on git bash, you go into your desired directory, and then type “git init”. By doing this, you made git like a personal security officer for that folder. Whatever goes on in that folder will be monitored by git. If a letter of a word in a file is changed, git will create a record and definitely let you know when you ask it.

Git status: This is your way of asking git for the events that have happened in the folder you asked it to monitor. When you type “git status”, git shows you every change that has occurred in that folder. If new files were added, or old ones were deleted, git keeps a record and displays it to you when asked. In my opinion, git status is probably the most used git command. I never get tired of using it. You should also make it a close pal, because we need to always know what’s happening in our files.

Git clone: If you are developer who uses a Git based hosted service like Github, you may want to clone a remote repository (like an online folder from github), to do this, you type “git clone” in your terminal followed by the link to the repository you want to clone. What cloning does is just as its name suggests, it creates a copy of everything in the remote repository, and puts it in your local computer. Different locations, same content. Terrific!

Git add: We talked about git being a super security officer for your folders right? but a security officer cannot track what never existed in the first place, hence we need to add all files and folders that we want tracked, to our git repository(folder whose contents are being tracked by Git). Git won’t track any folder that has not been added and committed to it through the git terminal. To do this, open your terminal (git bash or anyone you use), go to your desired directory using the “cd name of directory” command, then type “git status” to show you all folders that have been added or not added, after that you type “git add name of file”. There are different ways to use git add. If you want to add a specific file, you can type “git add name of file”, but if you want to add all the files available, simply type “git add -A” or “git add .” Using git add shows that the files added are ready to be committed.

Note that after adding a file, if you make a change before committing the file, you will need to use git add again.

Git commit: After adding your files to the Git repository, you need to commit it. This is like making a commitment with Git, telling Git the super security officer, to start tracking all activities and changes that happen to that file. By committing a file, the journey between your file or folder and Git has officially begun!

When you use git commit, you have to enter a commit message along with it. There are two ways to use git commit, you can choose to type “git commit”, when you do that, your default text editor is opened for you to enter a commit message. The other way is “git commit -m “message” “.

A commit message is basically a line or more of text explaining what changes were made in the files being committed. It is written like this:

git commit -m “this is a commit message”

A commit message has to be clear and explanatory, as much as some of us love to have fun while working, it is advised to keep the commit messages as clear as possible. Nothing like:

git commit -m “i am tired” or git commit -m “i give up”

Git, being nice and understanding, will accept those commit messages, but in a professional environment, let’s try to not use such messages.

Git log: Think about your phone’s call log, yeah, that list of all calls you have either received, made, or missed for a period of time are all displayed there. That is the same thing Git does when you type git log. It displays a history of all your git commits in a project; starting from the most recent commit to the oldest one. Quite detailed yeah? Git keeps the best things.

Git branch: When working with git, you can create as many branches as you want. Most people create branches to avoid unnecessary mistakes in their work. Let’s use Bally as an example. Bally is a writer, with two different versions of her book, Imran. One is free while the other is premium and can only be bought in some selected stores. Both books have very similar contents, but the premium one has some bonus chapters, and a special note from the author, Bally. When writing these books, Bally can create two different branches in git, and alternate between them as she adds and removes contents from them. One can be named “Imran free” and the other “Imran premium”.

How will she create these branches?

There are two ways to do it, the first way is to type

“git branch name of branch” then “git checkout name of the branch”. Git branch name of branch, is a way of creating a new branch and giving it a name, after doing that, git checkout name of branch is a way of going into that branch which you just created, and to start working in it.

The second way is more like a shortcut. Bally will type git checkout -b name of new branch. By doing this, she just created a new branch, and also moved into the branch with just a line of text.

Now that she has two branches in her git repository, when she wants to work on any one, she will use the git checkout name of that branch to go into it.

If she is in the Imran free branch, and wants to work on the premium book, she will simply type “git checkout Imran premium”, and git immediately switches branches to the Imran premium branch, and she can now work on the premium version of her book. Great!

Git checkout: This is a way to switch from one branch to another. I already mentioned it when explaining the git branch. Using git checkout is quite easy, you simply type “git checkout name of branch name you want to switch to” and voila! You are in your desired branch.

Git fetch: Git fetch is a git command used to download contents from a remote repository. To use git fetch, you type “git fetch name of remote branch”. Remember that a remote repository is the folder hosted on a Git based hosted service like github. So, when working with a team, you can use “git fetch” to download all the recent changes that your teammates have made, and see if you would like to merge them to your own work or not.

Git merge: Git merge is another command that you will definitely use a lot when working with teams or collaborating.

The git merge command takes a series of commits and makes them into one. Using git merge joins the branch you fetched (see git fetch above), to your current branch. It makes them become one branch.

To use git merge you type “git merge name of branch you want to merge”.

Note that git merge won’t work automatically if there is a place in both branches where different changes were made. If line twenty in branch A is “Hello world, I am Nike”, and line twenty in branch B is “Hello world, I am Akinsola”, Git will not know which one is supposed to be correct, so it won’t merge.You will need to correct those files manually.

Git pull: Git pull is a combination of two other commands; “git fetch” and “git merge”. Git fetch can be seen as a safer version of git pull because you download those contents from the remote repository and then check to see if you want to merge it with your work. With git pull, you download the contents and automatically merge them with your own work with just a single command. Cool yeah? Right.

To use git pull you type “git pull origin name of branch” or simply “git pull”,if you are working on a single branch.

Note that your files won’t merge automatically if there is a conflict like I described in the git merge explanation.

Git push: Hurray! You have worked tirelessly on your work(even if it is a single line change), now is the time to share it with other people. Git push is the command to send your work to the remote repository where others can see it. Most times, git push comes after the git pull command. This is because you need to make sure your local repository is updated, and the same with the remote repository before sending a new set of files to the remote repository. After adding your files, committing, and pulling from the remote repository, git push is often the command that comes next. To use git push, type “git push name of branch you want your work or changes pushed to”. And you are done!

Congratulations. 🎉🎉🎉

You came this far, which means that you now know the meaning of different Git terminologies and how to use them in your Git terminal. That is really great, I must commend you. Now remember, that you can only become great at something if you constantly practice; so don’t stop here, use Git as much as possible, and enjoy the amazing world of Git.

For more information on Git, you can check its official documentation page which is linked below. 👇

Git — Documentation