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:
A Working Directory - a working area where you work, make changes, and organize files.
A Staging Area - place to list the changes you are making in the Working directory.
A Repository - where git stores changes in a permanent versions of the project.
Using a Git Project
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.- As the project develops,
git status
can return the current state of changes to the project. - 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. - Example:
git add scene-3.txt scene-5.txt
- 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. - 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:
- a unique code identifier for the commit.
- The author of the commit
- The date and time of the commit
- The commit message.
How to Backtrack in Git
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:
Another useful backtracking is required when you realize you staged a file but you actually don't want to include it in your commit.
Finally, the git head can be reset to any previous commit using a command.
git checkout HEAD {filename}
This will restore the staged file to the last commit completed against it.
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.
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
.
