Git is an extremely important part of the workflow for anyone that uses programming, more so if you work as part of a team. Though it may be impossible to commit to memory all the commands due to the vast number of them, mastery is still possible and it begins by having a solid grasp of the fundamental commands and knowing them well.
Git is a distributed version-control system for tracking changes in any set of files, originally designed for coordinating work among programmers cooperating on source code during software development. Its goals include speed, data integrity, and support for distributed, non-linear workflows (Source: Wikipedia).
Note: The commands are not provided in order of importance. To learn more about Git, I highly recommend visiting the Documentation
Git Clone
Git clone is a command that is used to clone a remote repository into a new directory on your local drive. Simply, the command will create an identical copy of the latest commit made to a repository and save it to memory on your computer.
There are 2 ways to perform a clone. The first of these methods is using the Git command line to direct git to the repository you’d like to clone:
git clone https://github.com/kurtispykes/twitter-sentiment-analysis.git
This command would clone the twitter-sentiment-analysis repository from my remote Github repositories and save it to my local computer. The next method is to go to the Github repository and instead of copying the HTTPS to the clipboard (in order to past on the Git Command Line), you simply download the file as a ZIP.

Either way, the project will be in your local workspace and you can begin your wizardry.
Git Commit
I use this command every day. All this command does is record all the changes that has been made to the repository. Once we have modified, added, or deleted something from our project then we would stage the files and commit them.
Beware that git commit
only saves the changes locally and would be need to be pushed to the remote repository, but once we have done that we can always return to previous commits in the future – this is a life saver when your code breaks and you can’t seem to work out why… You simply roll back to a commit where the code was last working.
I generally like to add a message when committing my work so this is what it would look like:
git commit -m "Insert a Message"
Git Push
I mentioned that our commits would have to be pushed to a remote repository and git push
is exactly how that is done. The Documentation says this command will "Update remote refs along with associated objects". In lehmans terms, this means your commands would be uploaded to a remote repository – I don’t know why they didn’t just say that haha.
git push <remote> <branch-name>
Git Pull
Where there is a Push there is a pull – I think. Either way it sounds cool! The git pull command will fetch the most recent updates from the remote repository and will merge them with your local repository. Hence, git pull is a combination of the git fetch
and git merge
commands.
git pull <remote>
This is really useful because when you’re working in a team and someone makes a commit to the master, the branch you’re working on is different from the master branch so it would be disastrous if you were to merge your branch into the master without it being the latest version.
Git Branch
Think of a tree in autumn. The leaves have dropped to the ground and what we see is a tree with many branches that deviate from the main trunk of the tree. This is exactly how I recall the importance of Branches in git. By using branches, many people are capable of working on the same project in parallel.
The git branch allows you to list, create, or delete branches as follows:
git branch
orgit branch --list
– View all branchesgit branch <branch-name>
– Create a new local branchgit branch -d <branch-name>
– Delete a branch.
Git Status
git status
was the first command I learned when I began on my journey of git mastery. This command provides us with all the status of the current working tree. Information we can derive from this command are as follows:
- If the current branch is up to date
- If files are staged, unstaged, or untracked
- If there is anything that can be committed, pushed, or pulled
- If any files that have been newly created, modified, or deleted

Git Add
This was the second git command I learned – bare in mind, I already had the local files and I wanted to push them to a remote repository, hence why I learned git status
and git add
before the likes of git clone
and git branch
. What git add does is add file contents to the index because when we create, modify, or delete a file locally, the changes only occur locally unless we add them to be included in our next commit.
Generally, I’d add all files at once using git add .
but sometimes if I only want to add a single file then I’d do git add <file>
.

In Figure 2 the VERSION
file had been modified but was written in red writing meaning that it was an unstaged file (won’t be committed on the next commit). After adding the file, you can see in Figure 3 that the VERSION
file is now written in green writing meaning that it is staged for a commit.
Wrap Up
I first got started with Git when I was interning as a Machine Learning Engineer in 2019 and it was extremely useful for me whilst I worked with other team-mates. That’s not to say it’s only useful when working in teams. I still use git when working on my own and it has saved me numerous times. I recommend you learn, know, and use these commands as they will be very handy when you are working on your projects.
If you believe I’ve missed out on key commands, please do leave a response stating which ones and their functions.
If you’d like to connect with me, the best place to reach me is on LinkedIn. Let’s keep the conversation going…
If you enjoyed this post, you may also like:
Predicting Tweet Sentiment With Word2Vec Embeddings
Developing Proficiency With New Programming Languages and Frameworks