Before we get started, let’s answer the question “what is git?”. Git is a distributed version control system for keeping track of changes in source code during the software development process.

The goal of the platform is to make collaboration easier for teams on large projects. Git increases speed, integrity, and workflow efficiency. Git is used by more than 1,700 companies around the world (through different git platforms such as GitHub and GitLab).

Now for the fun stuff; how do you use Git?

## Using Git

For the purpose of this post, I am introducing git on the command line. This is the most common way to interact with a git platform. Let’s jump into it!

### Create a New Repository

Open a new directory and perform

git init

### Checkout a Repository

This will create a local copy of a git repository. Issue the following

git clone /path/to/repo

You may be asked to input your credentials to the git platform you are trying to access.

When you have made changes to the source code and you are ready to propose these changes to the repository, you will need to add the file (or files) to the Index using

git add <filename>
# OR
git add *

You have now successfully added the files(s) to your index. In order to actually commit these changes, we run the following command which will include a comment or message about the changers we made since the last commit.

 git commit -m "I made changes"

The files you made changes to have now been committed to the HEAD.

### Push Changes to Remote Repository

Now that we have successfully committed our changes to the HEAD, we need to push our changes to the remote git platform. This is done through the followign command:

git push origin master

where master is the name of the branch we are pushing these changes to.

### Get Changes from Remote Repository

If you are working in a repository with other people, you should always update your local repository to the newest commit so that you are certain you are working on the latest revision of the source code. Execute the following

git pull

Sometimes, you might have made local changes and need to override these changes with the latest code from the remote repository (important to note that this overrides and replaces all your local changes). This can be done by executing the following three (3) commands:

git checkout -- <filename>
git fetch origin
git reset --hard origin/master

Again, this will replace the selected files or repo’s local changes and restore it with the latest history from your git platform.

## Summary

This concludes this simple little guidance. I am working on another guide that goes more in-depth into how you can manage a git repository from the command line. In the meantime, check out another simple little guide here.

Thank you for taking 10 minutes out of your day to trust me to teach you something new. Feel free to leave me a comment below with your concerns or feedback.

I have half a decade of experience working with data science and data engineering in a variety of fields both professionally and in academia. I ahve demonstrated advanced skills in developing machine learning algorithms, econometric models, intuitive visualizations and reporting dashboards in order to communicate data and technical terminology in an easy to understand manner for clients of varying backgrounds.