- 专用名词
工作区:WorkSpace
暂存区:Index/Stage
仓库区(本地仓库):Repository
远程仓库:Remote - 新建代码库
git init
git init [project-name]
git clone [url]
- 配置
git config --list
git config -e [--global]
git config [--global] user.name "[name]"
git config [--global] user.email "[email address]"
- 增加/删除文件
git add [file1][file2] ...
git add [dir]
git add .
git add -p
git rm [file1][file2]...
git rm --cached [file]
git mv [file-original][file-renamed]
- 代码提交
git commit -m [message]
git commit [file1][file2] ... -m [message]
git commit -a
git commit -v
git commit -am 'message'
git commit --amend -m [message]
git commit --amend [file1][file2]...
- 分支
- 标签
- 查看信息
git status
git log
git log --stat
git log -S [keyword]
git log [tag] HEAD --pretty=format:%s
git log [tag] HEAD --grep feature
git log -follow [file]
git whatchanged [file]
git log -p [file]
git log -5 --pretty --oneline
git shortlog -sn
git blame [file]
git diff
git diff --cached [file]
- 远程同步
- 撤销
git checkout [file]
git checkout [commit] [file]
git checkout .
git reset [file]
git reset --hard
- 其他