Git Overview

Git is a software that enables tracking changes to a coding project over time. Git projects can be thought of as having 3 working parts:

  1. A Working Directory - a working area where you work, make changes, and organize files.

  2. A Staging Area - place to list the changes you are making in the Working directory.

  3. A Repository - where git stores changes in a permanent versions of the project.

Using a Git Project

  1. To start a Git Project, use the BASH terminal and navigate to where you intend to create a Git repositort. Type git init into the terminal to create the repository.

  2. A diagram of a Git Workflow.
  3. As the project develops, git status can return the current state of changes to the project.
  4. To add files to the git tracking, use git add filename. This will add files to the scope of the project. Multiple files can be added at once by seperating filenames by a space.
    1. Example: git add scene-3.txt scene-5.txt
  5. To check on changes to the files, use git diff filename for each file return a summary of what has changed since the last commit.
  6. A commit is the last step of a Git Workflow. To commit, type git commit -m "Insert a description for the commit here". The description should be 50 characters or less.

Checking the log

Git history can be checked to see a log of commits. This is done by typing git log into the terminal. The resulting text shows:

  1. a unique code identifier for the commit.
  2. The author of the commit
  3. The date and time of the commit
  4. The commit message.

How to Backtrack in Git

  1. In using Git, it may be necessary to backtrack a file that you have made a change to. To do this, use the following code command:

  2. git checkout HEAD {filename}

    This will restore the staged file to the last commit completed against it.


  3. Another useful backtracking is required when you realize you staged a file but you actually don't want to include it in your commit.


  4. git reset HEAD {filename}

    This script will reset the staged file to be the same as its last committed version. The file in the working directory won't be affected by this change.

  5. Finally, the git head can be reset to any previous commit using a command.

  6. git reset commit_SHA

    The commit_SHA is the first 7 digits of the long SHA code obtained from a previous git commit. These can be seen using the command Git log.


    A git reset diagram.