This post include notes to Pro Git book.
Git is a Distributed Version Control Systems (DVCSs).
Clients fully mirror the repository, including its full history.
Git thinks about its data more like a stream of snapshots.
Three Main File States
Git has three main states that your files can reside in:
committed, modified, and staged.
|Commited||The data is safely stored in your local database.|
|Modified||You have changed your file but have not committed it to your database yet.|
|Staged||You have marked a modified file in its current version to go into your next commit snapshot.|
This lead us to the three main sections of a Git project: the Git directory, the working tree, and the staging area.
Three Git Project Sections
|Git directory||Where Git stores the metadata and object database in your project. It is what you copied when you clone a repository from another computer.|
|Working tree||A single check out of one version of the project. These files are pulled out of the compressed database in the Git directory and placed on disk for your use or modify.|
|Staging area||A file, generally contained in your directory, that stores information about what will go into your next commit. Its technical name in Git parlance is “index“.|
Basic Git Workflow:
- You modify files in your working three.
- You selectively stage just those changes you want to be part of your next commit, which adds only those changes to the staging area.
- You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your git repository.
Reference: Installing Git
Reference: First Time Git Setup
1 Getting a Repository
1.1 Initializing a Repository in an Existing Directory
This creates a new sub-directory named .git that contains all of your necessary repository files – a git repository skeleton.
git add *.c git add LICENSE git commit -m 'initial project version'
1.2 Cloning an existing repository
git clone <url>
(1) creates a directory,
(2) initializes a .git directory inside it,
(3) pulls down all the data for that repository,
(4) and checks out a working copy of the latest version.