Pro Git Notes

This post include notes to Pro Git book.

Git Introduction

Git is a Distributed Version Control Systems (DVCSs).
Clients fully mirror the repository, including its full history.
Distributed Version Control
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.

StateDescription
CommitedThe data is safely stored in your local database.
ModifiedYou have changed your file but have not committed it to your database yet.
StagedYou 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

Working tree, staging area and Git directory.

SectionDescription
Git directoryWhere Git stores the metadata and object database in your project. It is what you copied when you clone a repository from another computer.
Working treeA 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 areaA 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:

  1. You modify files in your working three.
  2. You selectively stage just those changes you want to be part of your next commit, which adds only those changes to the 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 repository.

Installing Git

Reference: Installing Git

Git Config

Reference: First Time Git Setup

Git Basics

1 Getting a Repository

1.1 Initializing a Repository in an Existing Directory

Bash example:

cd %my_project%
git init

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

Bash command:

git clone <url>

This:
(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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值