Git version control (a)

First, Git deployment

[Official website address] https://git-scm.com/
[download] CSDN

All in accordance with the default installation is ~

Second, common operations

1, the deployment of code repository

Configuration status:

git config --global user.name "用户名"
git config ---global user.email "邮箱地址"

Create a code repository:

git init

2, submitted to the local code

Add code to submit:

git add 文件名/目录名

Add all of the files:

git add .

Submit code:

git commit -m "要备注的信息"

3, ignore files

There is a directory named under the code .gitignorefile, the contents of which are not added to version control:
Here Insert Picture Description

4, modify the content view

Check the revision of the file:

git status

Here Insert Picture Description
Compare file changes:

git diff 文件名

Here Insert Picture Description

5, the revocation of uncommitted changes

Undo file is not added:

git checkout 文件名

Here Insert Picture Description
Undo last 已添加state:

git reset HEAD 文件名

Here Insert Picture Description

7, see the commit record

View historical submit information:

git log

Here Insert Picture Description
View one record:

git log ID -1

Here Insert Picture Description
View details:

git log ID -1 -p

Here Insert Picture Description

Published 156 original articles · won praise 13 · views 7207

Guess you like

Origin blog.csdn.net/qq_41205771/article/details/104247155