Small c to learn Git (1)--10 minutes to understand the essence of git

Youtube video learning address: https://youtu.be/etTDkZiW1Ng?list=WL

Install Git

1) Download Git

yum -y install git

2) Username and email must be set for the first use

git config --global user.name "caijun"
git config --global user.email "[email protected]"

3) View configuration information

git config --list

Create a Git repository

create your own git repository

1) Create a repo file specifically for git

mkdir /git/myrepo

2) Initialize the git repository under this file

cd /git/myrepo

git init

clone someone else's git repository

1) Clone other people's warehouses to the local

cd /git/

#会在/git目录下创建一个名为example的git仓库
git clone git://git.com/example.git

Basic Git Operations

#索引状态
git status

#建立blob对象,添加到index
git add file_name

#提交变更,自动将blob添加到tree,将tree添加到commit,Snapshot一个commit快照
git commit -m "DESCRIPTION"

#相当于add + commit
#建立blob对象,提交到index,并且生成tree,commit快照,一步完成
git commit -a -m "DESCRIPTION"

repository, working directory, index

write picture description here

There is a hidden .git folder in the working directory, which is the location of the repository, .git contains the index, and index is the location of the index.

commit architecture, Snapshot snapshots and branches

commit architecture

write picture description here

snapshot

write picture description here

branch

write picture description here

write picture description here

write picture description here

write picture description here

write picture description here

Four states of the working directory:

write picture description here

The picture and text are easy to understand the whole process

Create a new file, only git add can create blob, map to index

write picture description here

Commit
write picture description here

change file

write picture description here

The next step is to commit directly, which has no effect on index and repository, only git add generates blob and index

write picture description here

commit commit, generate tree and commit snapshot

write picture description here

Modify the files in the working directory again, and git commit -a -m "DESCRIPTION"complete the submission in one step

write picture description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325730990&siteId=291194637