Here is a quick table on what you need to do to get git installed and configured on your machine:

1. Install git
2. Configure identity git config --global "John Smith"
git config --global ""
3. Configure ignored files Add entries to the repository's .gitignore file.

Your First Repo

Here is a recap of the commands required to create your first repo:

1. Create a project directory

$ mkdir git_basics
$ cd git_basics
git_basics/ $ echo '# README #' >
git_basics/ $ echo '# LICENSE #' >

2. Initialize the git repository

git_basics/ $ git init

3. Create a .gitignore file

git_basics/ $ touch .gitignore

Now add entries to the .gitignore file. In the below example, we're going to ignore all sqlite databases in our project. Add the following to the git_basics/.gitignore file:

# Ignore all sqlite databases

4. git status

If you run the git status command, you will see the following:

On branch master

Initial commit

Untracked files:
  (use "git add <file>..." to include in what will be committed)


nothing added to commit but untracked files present (use "git add" to track)

This shows us that we currently have three files with changes that are not currently staged. If you took a look at your repository with a git GUI application you should see something like this (we're using gitx below):

You can see that it is showing the same information. Three files with unstaged changes, and no files with staged changes.

5. Stage the changed files

Use git add <file> to now stage the affected files.

git_basics/ $ git add .gitignore
git_basics/ $ git add
git_basics/ $ git add

Now we can do git status again after staging those files:

On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

	new file:   .gitignore
	new file:
	new file:

You can see the changes are now in a "Changes to be committed" state. If we look in the GUI application again, you will see the files are now marked as staged:

6. Commit the changes to our repository

git_basics/ $ git commit -m 'Add first project files'

Now, if we do a git status, our status now shows that there are no more changes that need to be committed:

On branch master
nothing to commit, working directory clean

7. git log

To verify that the commit was indeed created, use git log to see a historical version of commits, and you should see the last commit created:

commit 8466981224ab4b6837b95d9f8208cd345569267c
Author: John Smith <>
Date:   Mon Oct 6 15:24:38 2014 -0700

    Add first project files

Command Reference

Here is a reference to all of the commands that we have learned so far, along with their purpose. Notice that they all interact with the local system or repository. These commands are never used to interact with remote repositories.

Command Purpose
git init Creates a new repository in the current directory. Generates a .git directory.
git config Sets git configuration settings, such as author email and name.
git status Shows the working directory as well as the staged changes. Run this command liberally to see which changes are ready for committing.
git add <filename> Stage file changes, which prepares them to be added to the repository.
git commit -m "commit message" Creates a commit from staged files. Commits are the atomic unit in git that gets moved around between branches and repositories.

Local vs. Remote Revisited

Because git is a distributed version control system, one of the most confusing and also most important things to remember is the difference between local vs remote repositories. Local repositories are located on your computer, and remote repositories are located on a remote server. You will always issue git commands within a local git repository. Later, you will learn how to work with remote repositories from a local repository.