- 查看工作区暂存区状态
git status
- 将工作区的 新建/修改 提交到暂存区
git add
- 移除暂存区的文件
git rm --cached 文件名
- 将暂存区文件提交到本地库
git commit 文件名
git commit -m "本次提交说明“ 文件名
- 查看日志
显示日志
git log
以一行的形式显示日志
git log --pretty=oneline
git log --oneline
git reflog
示例
$ git status
On branch master //在主分支上
No commits yet //尚未提交
nothing to commit (create/copy files and use "git add" to track)//没有什么东西可以提交
创建一个txt文件查看状态,使用git add提交文件到暂存区 ,除暂存区文件
$ vim good.txt
$ git status
On branch master
No commits yet
Untracked files: //未追踪的文件
(use "git add <file>..." to include in what will be committed)
good.txt
nothing added to commit but untracked files present (use "git add" to track)
//将文件提交到暂存区
$ git add good.txt
//将文件从暂存区移除
$ git rm --cached good.txt
rm 'good.txt'
$ git commit good.txt //提交文件到本地库 提交进入以下界面输入本次提交信息
// :set nu显示行号
// i 进入编辑模式
// esc退出编辑模式
// :wq保存并退出
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch master
#
# Initial commit
#
# Changes to be committed:
# new file: good.txt
#
//保存退出返回以下内容
warning: LF will be replaced by CRLF in good.txt.
The file will have its original line endings in your working directory
[master (root-commit) eb9f1b9] My first commit.new file good` //本次提交id 、次数、提交信息
1 file changed, 3 insertions(+) //修改你文件个数 和行数
create mode 100644 good.txt