配置用户信息
git config –global user.email “ropon@west.cn“ git config –global user.name “Ropon”
初始化
cd /home/work git init
查看状态
git status
新建忽略文件或文件件配置文件
touch .gitignore cat .gitignore .idea .exe .sql
添加到缓存区
git add .
提交到版本库
git commit -m “备注信息”
查看提交记录
git log
查看所有提交记录
git reflog
从缓存区将文件拉到工作区
git reset HEAD main.go
撤销之前修改回到上次提交时状态
git checkout – main.go
回滚到某个版本
git reset –hard 9c3c9f8 或 4a04c2b3661b70478af9032dd7e72455e73d86fb
对比工作区与缓存区的差异
git diff
对比版本库与缓存区的差异
git diff –cached
将当前工作区文件暂存到某个地方
git stash
查看stash列表
git stash list
将暂存恢复到当前工作区并删除此暂存
git stash pop
将暂存恢复到当前工作区但不删除此暂存
git stash apply
删除stash
git stash drop
新建分支
git branch 分支名
查看分支
git branch
切换到某个分支
git checkout 分支名
删除分支
git branch -d 分支名
创建分支并切换到该分支
git checkout -b 分支名 基于某个tag创建新分支 git branch 分支名 tab名称 git checkout 分支名
打标签
git tag -a v1.0 -m “备注信息”
查看标签
git tag
1 |
|
1 | 撤销commit |
1 |
|