Tech Notes

Git & GitHub for Beginners

Get Started with GIT

Install Git on your computer

Before you start using Git you need to install it on your computer. It is pretty straight forward. Just follow the link below:

Download Git

Once you have installed Git you can begin a new repository for any project you want!

Initializing Git to start tracking your files.

Git is version control software. It keeps track of every change you make to your files. This allows you the freedom to go back to an earlier rendition of your h4 if things go awry. Another handy feature is the ability to work on branches, only merging to your main project once everything is working properly.

In order for Git to track your changes you need to start a repository for your project directory. After you create your directory, then use the 'git init' command in your terminal. (Instructions below) Git init is short for git initialize, and this command begins a repository for your project directory.

Once you have initialized your git repository, then any files or other assets you add to the directory will be added to the list of items to be saved when you commit. You can prevent certain things from being added if you want.


To start: you need to open your command prompt, powershell, or terminal. Once you have opened your prompt, navigate to the directory (folder) you want to track using git. Next type in the following command and hit enter:

git init

Now your directory is being tracked by git, and this repository that you just created will record all of the changes you make to your code.

I am using Visual Studio Code, which has a built in terminal. If you have your folder open and open a new terminal in VSC it will already be in the current directory. There are also tools you can use for git in VSC that do not require using the terminal.

Whether you use the terminal, or the tools in your editor to work with Git, the steps are the same and proceed in the same order. I suggest learning how to use the terminal first, but you can do it either way.

Now you have initialized a git repository to keep track of your files, what's next?

back to top

Staging your changes so you can save, or commit them.

You have done some work on your project and now you want to save it, along with each change you've made along the way. In Git, a save is called a commit, and before you make a 'commit' you have to 'stage' your changes.

Here is how to do it, return to your command prompt and type in the following:

git status

This will get you a list of files and other assets from your directory that need to be staged in red, and those already staged in green.

git add filename

'filename' means the name of your file, for example index.html.

If you have changes across several files within your directory you can simply type in:

git add -A

This will add all of the files in the current directory that have changes to the staging area. Now that the files are staged, they are ready to commit.You can check you git status agin and you will see everything that is staged is now colored green, which means it is ready to commit.

back to top

Saving your changes, which is called committing in Git.

Now your files are staged and ready to save. To do this you use the 'git commit' command. When you use 'git commit' you are also required to add a message about the changes. You do this by appending the message tag(-m) followed by the message to your commit command:

-m "message about changes"

The full command is written below:

git commit filename -m "message about changes"

Your message is about the changes you have made to your code since the last commit. Normally once your files are made, you do an initial commit and the message is just "initial commit" This is before you add any code, or maybe once you add the very basic bits.

Normally the advice is to commit often. It makes it easier to find code that is causing problems, or go back before unwanted changes were made. Each commit is a record of every change you made to every file included in that commit. Just something to keep in mind.

Just like staging, you can also use the ' . ' to include all files that are staged to commit. Once you commit, your latest version is saved to your repository. Your previous versions are also saved, so you can go back to them if needed or desired. But what if you want to share them, maybe even collaborate with others? That's what GitHub is for.

back to top