Git Basics

Git Basics

  • Before we can understand how git saves files, we need to cover some concepts about how git works

Three States of a Git file

  • Git has three main states that your files can reside in: committed, modified, and staged

    • committed: files that have been saved / recorded to the repository’s history

    • staged: files that have been modified

    • modified: files that has been modified but have not yet been staged and committed to project’s history


Git Projects have three main sections

  • Git projects are broken up into three main sections:

inline

  • Working Directory - where all the recent “unstaged” changes (since your last commit) reside

    • modified files reside in the Working Directory
  • Staging Area where all your staged changes live ; stores information about what will go into your next commit (i.e. changes to be committed)

    • staged files reside in the staging area
  • Git directory (repository) where all the changes throughout history of a git project are permanently stored; changes are recorded to the Git directory through the use of commits

    • committed files reside in the git directory / repository

Typical Git Workflow

  • The basic Git workflow goes something like this:

    1. You modify files in your working directory

    2. You stage the files, adding snapshots of them to your staging area

    3. You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory