Skip to content

Commit f12215d

Browse files
committed
新增分支切换操作方式
1 parent 85b9a05 commit f12215d

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,61 @@
33
## 常用操作
44

55
### clone 已有仓库
6+
67
```
78
$ git clone [email protected]:lw1024/Git-learning-notes.git
89
```
910

1011
### 查看当前状态
12+
1113
```
1214
$ git status
1315
```
1416

1517
### 提交
18+
1619
```
1720
$ git add [要提交的文件]
1821
$ git commit -m "提交信息描述"
1922
```
2023
### 查看提交日志
24+
2125
```
2226
$ git log
2327
```
2428

2529
### 进行 push
30+
2631
```
2732
$ git push
2833
```
2934

3035
## 基本操作
3136

3237
### git init——初始化仓库
38+
3339
```
3440
$ mkdir git-tutorial
3541
$ cd git-tutorial
3642
$ git init
3743
```
3844

3945
### git status——查看仓库的状态
46+
4047
```
4148
$ touch README.md
4249
$ git status
4350
```
4451

4552
### git add——向暂存区中添加文件
53+
4654
```
4755
$ git add README.md
4856
$ git status
4957
```
5058

5159
### git commit——保存仓库的历史记录
60+
5261
```
5362
$ git commit -m "First commit"
5463
```
@@ -69,6 +78,7 @@ $ git commit -m "First commit"
6978
> 如果在编辑器启动后想终止提交,请将提交信息留空并直接关闭编辑器,随后提交就会被终止。
7079
7180
### git log——查看提交日志
81+
7282
```
7383
$ git log
7484
```
@@ -92,11 +102,13 @@ $ git log -p README.md
92102
### git diff——查看更改前后的差别
93103

94104
**查看工作树和暂存区的差别**
105+
95106
```
96107
$ git diff
97108
```
98109

99110
**查看工作树和最新提交的差别**
111+
100112
```
101113
$ git add README.md
102114
$ git diff HEAD
@@ -106,6 +118,7 @@ $ git diff HEAD
106118
## 分支的操作
107119

108120
### git branch——显示分支一览表
121+
109122
```
110123
$ git branch
111124
* master
@@ -115,6 +128,7 @@ $ git branch
115128
### git checkout -b——创建、切换分支
116129

117130
#### 切换到 feature-A 分支并进行提交
131+
118132
```
119133
$ git checkout -b feature-A
120134
Switched to a new branch 'feature-A'
@@ -125,3 +139,19 @@ $ git branch feature-A
125139
$ git checkout feature-A
126140
```
127141

142+
#### 切换到 master 分支
143+
144+
```
145+
$ git checkout master
146+
Switched to branch 'master'
147+
```
148+
149+
#### 切换回上一个分支
150+
151+
```
152+
$ git checkout -
153+
Switched to branch 'feature-A'
154+
```
155+
156+
[TOC]
157+

0 commit comments

Comments
 (0)