一、概念
- 裸仓库:不包含工作区,通常作为远端的中心仓库而存在
- 克隆的裸仓库可以本地 push,普通仓库无法进行本地 push
- 裸仓库不含工作区,不会存在在裸仓库上直接提交变更的情况
- 区域划分:工作区,暂存区,本地库
-
二、操作
1. 配置
全局配置用户名与邮箱
git config --global user.name "your name"
git config --global user.email "youremail@github.com"
- 当前仓库配置用户名与邮箱
git config --local user.name "your name"
git config --local user.email "youremail@github.com"
2. 分支管理
- 创建分支
git checkout -b 新分支名称
基于当前分支创建新分支,并切换到新分支
- 切换分支
git checkout <分支名称>
- 查看分支
git branch
查看本地分支git branch -r
查看远程分支git branch -a
查看本地和远程分支
- 删除分支
git branch -D <分支名称>
删除本地分支git branch origin -d <远程分支名称>
删除远程分支
合并分支
查看状态
git status
- 查看历史操作记录
git reflog
查看日志
添加改动到stash
git stash push -m "message"
- 查看stash列表
git stash list
- 恢复改动
git stash pop <stash@{ID}>
pop: 取会删除对应的保存记录git stash apply <stash@{ID}>
apply: 取但保留记录
删除全部缓存
撤销工作区修改
git checkout .
版本回退
- https://juejin.cn/post/6844904149465710599#heading-46
- https://www.processon.com/view/link/5fd224bfe0b34d06f4ec645a