GIT指令

工作区->暂存区->仓库区

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#创建仓库
git init
#创建文件
touch file.txt
#查看文件状态
git status
#提交文件到暂存区
git add file.txt
#通配符提交所有文件
git add .
#提交文件到仓库区
git commit -m "add file"
#查看提交日志
git log
#版本切换
git reset --hard commitID
#查看删除的提交记录
git reflog
#创建不需要git管理的文件库
touch .gitignore

分支

1
2
3
4
5
6
#查看分支
git branch
#创建分支
git branch br1
#切换分支
git checkout br1

远程仓库

1
2
3
4
5
6
#关联仓库
git remote add origin https://github.com/jww128/gittest.git
#首次上传文件
git push -u origin main
#后续上传文件
git push

http://example.com/2026/05/19/工具/git/
作者
John Doe
发布于
2026年5月19日
许可协议