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
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
snapshot
branch
write picture description here
Four states of the working directory:
The picture and text are easy to understand the whole process
Create a new file, only git add can create blob, map to index
Commit
change file
The next step is to commit directly, which has no effect on index and repository, only git add generates blob and index
commit commit, generate tree and commit snapshot
Modify the files in the working directory again, and git commit -a -m "DESCRIPTION"
complete the submission in one step