Compare commits

..

No commits in common. "4bdf9b82bcd48e3407534088fe6a88a25eafa980" and "32575fda962159646e38e913fee0ca1b8acc1c10" have entirely different histories.

3 changed files with 0 additions and 43 deletions

View File

@ -1,42 +0,0 @@
## 2.5 Git Checkout
### 2.5.1 HEAD reset = checkout
查看当前的branch
```bash
git branch -v
```
checkout到commit的父亲使得head指针指向父提交而不是branch
```bash
git checkout <commit>^
```
在detach模式下addcommitHEAD都是指向最新的提交
之后再checkout到原来的分支detach模式下的操作记录都会丢失
### 2.5.2 git merge
```bash
git merge <commit>
```
<commit>提交合并到当前分支,这样做就可以把detach模式下的提交merge到当前分支上
合并以后的提交将有两个父提交
### 2.5.3 git checkout
```bash
用法一: git checkout [-q] [<commit>] [--] <paths>...
用法二: git checkout [<branch>]
用法三: git checkout [-m] [[-b|--orphan] <new_branch>] [<start_point>]
```
第一种用法的`<commit>`是可选项如果省略则相当于从暂存区index进行检出。reset的默认值是 HEAD而checkout的默认值是暂存区。
reset的目的是用HEAD重置暂存区checkout是想暂存区中覆盖工作区的内容
第二种用法就是切换分支
第三种用法是新建分支

View File

@ -1,2 +1 @@
welcome
1039