相关概念:
- 工作区:就是仓库本身,除了隐藏文件 .git
- 版本库:就是 .git 文件,里面有很多东西,,最重要的就是 stage,称为暂存区。还有分支master及对应的指针。
- 暂存区:
git add
添加文件到暂存区
- git add filename:添加指定已修改的文件
- git add . :添加所有已修改的文件
git commit -m "提交说明"
添加文件到当前分支
git status
查看仓库状态,哪些文件被修改
git diff filename
查看具体的修改内容
git log
显示最近到最远的提交日志
$ git log
commit 1094adb7b9b3807259d8cb349e7df1d4d6477073 (HEAD -> master)
Author: Michael Liao <askxuefeng@gmail.com>
Date: Fri May 18 21:06:15 2018 +0800
append GPL
commit e475afc93c209a690c39c13a46716e8fa000c366
Author: Michael Liao <askxuefeng@gmail.com>
Date: Fri May 18 21:03:36 2018 +0800
add distributed
commit eaadf4e385e865d25c48e7ca9c8395c3f7dfaef0
Author: Michael Liao <askxuefeng@gmail.com>
Date: Fri May 18 20:59:18 2018 +0800
wrote a readme file
git log --pretty=oneline
$ git log --pretty=oneline
1094adb7b9b3807259d8cb349e7df1d4d6477073 (HEAD -> master) append GPL
e475afc93c209a690c39c13a46716e8fa000c366 add distributed
eaadf4e385e865d25c48e7ca9c8395c3f7dfaef0 wrote a readme file
git reset --hard "commit-id"
版本回退
$ git reset --hard 1094a
HEAD is now at 83b0afe append GPL
网友评论