git命令总结
[toc]
1.git简介
1.1 git工作流程

1.2 git四种状态

2.git命令总结
2.1 git工作区域及文件颜色

git status 文件三种颜色的变化
红色- 新增文件或者修改的旧文件-->执行命令
git add .或者git add 文件名
- git已经管理起来的文件-->执行命令
git commit -m '描述信息'
白色
- 已经生成版本的文件
2.2 git提交数据
创建文件
$ touch aaa bbb
查看git文件状态(此时文件是红色的,属于新增文件)
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
aaa
bbb
nothing added to commit but untracked files present (use "git add" to track)

提交文件至暂存区
$ git add .
此时再查看文件,文件是绿色的,已被git管理起来
$ git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: aaa
new file: bbb

2.3 git删除数据
2.3.1 git删除暂存区中的文件 git rm --cached
git删除暂存区中的文件
$ git rm --cached aaa bbb
rm 'aaa'
rm 'bbb'
此时文件变回红色
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
aaa
bbb
nothing added to commit but untracked files present (use "git add" to track)

2.3.2 git删除工作区和暂存区中的文件 git rm -f 文件名
查看暂存区中的文件,此时是绿色的
$ git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: aaa
new file: bbb

删除工作区的文件同时暂存区中的文件也会同时被删除
$ git rm -f aaa bbb
rm 'aaa'
rm 'bbb'
$ ls
$ git status
On branch master
nothing to commit, working tree clean