01. The Three States and Areas of Git

In order to fully understand Git, we have view our files how Git does. Envisioning what states your files are in will allow you to quickly pick up on the Git commands. Git views all files in three ways:

  1. committed
  2. modified/untracked
  3. staged

In addition to these three states, Git files live in one of three areas: the working directory, staging area, and the git directory (aka your local repository). Note that a repository is just a fancy name for a folder under version control.

The manipulation among all the above states occur locally, meaning that the changes affect no one else's current repository but yours (we'll discuss remote repositories - or those that are located on a server - soon).

Three stages of Git.
Try to envision your files as Git does - this will make the learning process a whole lot easier.

1) Modified/Untracked and your Working Directory

Git views untracked and modified files similarly. Untracked means that the file is new to your Git project. Modified means that the file has been seen before, but has been changed, so is not ready to be snapshotted by Git. Modification of a file occurs in your working directory.

2) Staged and Staging Area

When a file becomes staged, it's taken into the staging area. This is where Git is able to take a snapshot of it and store its current state to your local repository. This area is also known as the Index.

3) Committed and the Git Directory

Committed means that Git has officially taken a snapshot of the files in the staging area, and stored a unique index in the Git directory. The terms snapshotted and committed are very similar. The significance of being committed is that you can now revert back to this project's current state at any time in the future.

The term for the very last snapshot you've made for commitment is known as the HEAD.

It's very important to understand the three states of a file, and the three areas they live in! If you have a good handle on these concepts, the rest of Git fundamentals should be a cinch!

Take your Linux skills to the next level!

The Linux Command Line

Take your Linux skills to the next level! Try Linux & UNIX

The Linux Command Line takes you from your very first terminal keystrokes to writing full programs in Bash, the most popular Linux shell. Along the way you'll learn the timeless skills handed down by generations of gray-bearded, mouse-shunning gurus: file navigation, environment configuration, command chaining, pattern matching with regular expressions, and more.

$ Check price
39.9539.95Amazon 4.5 logo(274+ reviews)

More Linux & UNIX resources

Learn to be a Pythonista!

Programming for Beginners

Learn to be a Pythonista! Try Python

This book doesn't make any assumptions about your background or knowledge of Python or computer programming. You will be guided step by step using a logical and systematic approach. As new concepts, commands, or jargon are encountered they are explained in plain language, making it easy for anyone to understand.

$ Check price
24.9924.99Amazon 4.5 logo(124+ reviews)

More Python resources

Ad