Basic Git Tutorial Crash Course

Git is a code repository. It allows you to save versions of code and collaborate remotely using Here are the basics of how to use git:

Basic Requirements

You will need the following:

  • a Git Hub Account
  • a Code Repository
  • a git client to talk to the repository

Examples in this document are using random push and pulls and do not match. They are all isolated examples.

Create a Github Account

This is pretty self explanatory – just go to and create a new account. It’s free.

Creating a Code Repository

Once you have an account, click on the Repositories tab and create a new one:

Next, you’ll want to create a repo by giving it a name and deciding if you want it public or private. If you make it public, you won’t have to create git keys using an authentication token. I would also choose to create the README. I am using a repo name called “ssl-verify” but you can make your repo name anything you want.

In the example below I have two repos creating so far. The first one is called “verses” and the second “svggames“. The screen is not showing the “ssl-verify” repo that I created in our example.

Git repo list

It is possible to have other code repositories besides github. Specifically your company may give you a URL to use. Github is the public repository that everyone can use and it works the same for the commercial/private code servers (mostly).

Installing a Git Client

You can run the git client on Windows, Mac, Linux, etc. Whatever OS you have, it has a git client.

To install git on debian/ubuntu (such as a Raspberry Pi) based systems, type:

If you are on windows and can use CLI, I prefer Cygwin. This tutorial will go over CLI version. If you need a GUI in windows, there are several git windows clients to choose from, both free and paid:

There are at least 20 gui clients for mac, linux and windows in this list of clients on I personally use the cygwin client.

Using Git

Now that you have an account, a repository and a client, you can begin working in git.

The basic steps are:

  • Clone your repo
  • Add/Modify Files
  • Commit Files to Change List
  • Push Files to Repo

Cloning a Git Repository

Cloning takes the copy of files in a repo and moves them to your current directory, locally. You will need to get the repo URI. This is in the format of:

For example, my svggames repo is shown when I click the clone or download box:

Git Clone Repo

Now that I have the .git location URI, I can use it in the CLI or client of your choice:

At this point all of the files in the repo have been downloaded to my local directory in a folder called “svggames”. So I will change to that directory and being coding/modifying/whatever (I use CLI, so I actually type):

If I wanted to get in the habit of checking git status, it would show that nothing is modified (this is true, because I just downloaded it a few seconds ago).

Add/Modify Files

Now if I wanted to modify a file, I can open it locally and make my changes or even use the code as-is – assuming there is a run/install script there. If I make changes, Git will recognize that the file has changed. For tutorial purposes, assume that I have modified the with a few more tips or instructions and want to upload it. I can verify what git client sees by using the “git status” command after Ive modified the

Git is telling me I need to commit add a file and then commit.

Commit Files to Change List

We will commit our list of files later, but first we have to add which files will be in that list. The command is simply “git add ” and it does not return anything:

Commiting a File

Committing allows us to add a comment to each commit. I like to add a file, then commit, then push – one at a time. This keeps my logs clear on what I am doing.

Git tells me the files changed and the comment has been included “Created initial README info”. This will show up later when I check git logs, or in the repo for my account and repo “” if anyone reviews it later.

Pushing Files to Repo (Merge)

Finally I have made changes, told git which files I want uploaded using the “add” command, committed them with a comment using the “commit” command. My final step is to upload them using the “push” command:

Looking in the web view, I can see my commit a few minutes ago, and the new commit comment:

git committed

Pushing Files to Repo (Overwrite)

If you want to simply overwrite what is in the repo with your local copy, and ignore what is there, you can use the force (Luke):

Git Pull (Merge)

If I wanted to collaborate and someone else was working on the code with me, or if I had code in multiple locations (such as home/office), I could use git pull to get an updated version of the code before I started doing my own edits. If there were changes git would tell me details of those changes, or it would go ahead and do the code merge from the remote to my local code:

Git Pull (Overwrite)

In the event that you want to overwrite your local copy from the repo you might get this message:

A git reset will ignore your local changes and allow you to do a git pull without asking for a merge.

Now your merge works:

Git Log Review

I could also review all of the changes I made to help me decide what I might need to roll back. Here is a sample of the session that matches what we just did:

Ignoring Files/Folders

The .gitignore file will allow you to ignore changes done to files in certain locations (folders/files). Edit it and add in things you don’t want to synchronize:

For example, you may not want your entire python environment uploaded to github, so you would exclude files and directories by adding these lines in your .gitignore file:

Usage Summary

Here is a quick reference to help you with the basics:

git clone
Downloads the repo to your local device
git add
Adds files to the tracking list
git commit
Adds all tracked files to the commit queue
git push
Uploads all of the commit queue to your remote repo
git push –force
Uploads all of the commit queue to your remote repo, overwriting without a merge
git pull
Downloads any changed files to your local repo
git reset –hard
Downloads any changed files to your local repo, ignoring your changes and simply overwriting your files
git status
Shows what git knows about, what has changed
git log
Shows all commits and their comments

That is the basic method for creating a repo, and managing files in it. There are many other git commands for branching, adding users, making things private, creating projects, workflows and more. Git is a robust code management solution and should be something you know how to access, and use if you work with code.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.