Git Basic Concepts

Published:
Last modified:

Stream of snapshots

Git saves data like a stream of snapshots. Every time you commit, or save the state of your project in Git, it basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot. if files have not changed, Git doesn’t store the file again, just a link to the previous identical file it has already stored.

Integrity

Git has integrity. Everything in Git is check-summed before it is stored and is then referred to by that checksum. It uses SHA-1.

File states

There are three file states:

  • Committed means that the data is stored in your local database.
  • Modified means that you have changed the file but have not committed it to your database yet.
  • Staged means that you have marked a modified fi\e in its current version to go into your next commit snapshot.

Lifecycle of the status of files

sequenceDiagram Untracked ->> Staged: Add the file Unmodified ->> Modified: Edit the file Modified ->> Staged: Stage the file Unmodified ->> Untracked: Remove the file Staged ->> Unmodified: Commit

Main Sections

Sections of a Git project:

  • the Git directory is where Git stores the metadata and object database for your project. It is copied when cloning a repo.
  • the working directory is a single checkout of one version of the project. These files are pulled out of the compressed database in the Git directory and placed on disk for you to use or modify.
  • the staging area is a file, generally contained in your Git directory, that stores information about what will go into your next commit. It’s sometimes referred to as the index.
graph TB git["Git Project Sections"] git==>dir["the Git directory
.git"] git==>stage["Staging Area"] git==>work["Working Directory"]
Uruguay
Marcelo Canina
I'm Marcelo Canina, a developer from Uruguay. I build websites and web-based applications from the ground up and share what I learn here.
comments powered by Disqus

    Articles

    • Git Basic Concepts

Except as otherwise noted, the content of this page is licensed under CC BY-NC-ND 4.0 . Terms and Policy.

Powered by SimpleIT Hugo Theme

·