File tree 1 file changed +30
-0
lines changed
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 3
3
## 常用操作
4
4
5
5
### clone 已有仓库
6
+
6
7
```
7
8
$ git clone [email protected] :lw1024/Git-learning-notes.git
8
9
```
9
10
10
11
### 查看当前状态
12
+
11
13
```
12
14
$ git status
13
15
```
14
16
15
17
### 提交
18
+
16
19
```
17
20
$ git add [要提交的文件]
18
21
$ git commit -m "提交信息描述"
19
22
```
20
23
### 查看提交日志
24
+
21
25
```
22
26
$ git log
23
27
```
24
28
25
29
### 进行 push
30
+
26
31
```
27
32
$ git push
28
33
```
29
34
30
35
## 基本操作
31
36
32
37
### git init——初始化仓库
38
+
33
39
```
34
40
$ mkdir git-tutorial
35
41
$ cd git-tutorial
36
42
$ git init
37
43
```
38
44
39
45
### git status——查看仓库的状态
46
+
40
47
```
41
48
$ touch README.md
42
49
$ git status
43
50
```
44
51
45
52
### git add——向暂存区中添加文件
53
+
46
54
```
47
55
$ git add README.md
48
56
$ git status
49
57
```
50
58
51
59
### git commit——保存仓库的历史记录
60
+
52
61
```
53
62
$ git commit -m "First commit"
54
63
```
@@ -69,6 +78,7 @@ $ git commit -m "First commit"
69
78
> 如果在编辑器启动后想终止提交,请将提交信息留空并直接关闭编辑器,随后提交就会被终止。
70
79
71
80
### git log——查看提交日志
81
+
72
82
```
73
83
$ git log
74
84
```
@@ -92,11 +102,13 @@ $ git log -p README.md
92
102
### git diff——查看更改前后的差别
93
103
94
104
** 查看工作树和暂存区的差别**
105
+
95
106
```
96
107
$ git diff
97
108
```
98
109
99
110
** 查看工作树和最新提交的差别**
111
+
100
112
```
101
113
$ git add README.md
102
114
$ git diff HEAD
@@ -106,6 +118,7 @@ $ git diff HEAD
106
118
## 分支的操作
107
119
108
120
### git branch——显示分支一览表
121
+
109
122
```
110
123
$ git branch
111
124
* master
@@ -115,6 +128,7 @@ $ git branch
115
128
### git checkout -b——创建、切换分支
116
129
117
130
#### 切换到 feature-A 分支并进行提交
131
+
118
132
```
119
133
$ git checkout -b feature-A
120
134
Switched to a new branch 'feature-A'
@@ -125,3 +139,19 @@ $ git branch feature-A
125
139
$ git checkout feature-A
126
140
```
127
141
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
+
You can’t perform that action at this time.
0 commit comments