@@ -154,7 +154,7 @@ Git 有三种状态,你的文件可能处于其中之一:
154154 主体部分当然也可以有几段,但是一定要注意换行和句子不要太长。因为这样在使用 "git log" 的时候会有缩进比较好看。
155155
156156提交的标题行描述应该尽量的清晰和尽量的一句话概括。这样就方便相关的 Git 日志查看工具显示和其他人的阅读。
157-
157+
158158### 推送改动到远程仓库
159159
160160- 如果你还没有克隆现有仓库,并欲将你的仓库连接到某个远程服务器,你可以使用如下命令添加:·` git remote add origin <server> ` ,比如我们要让本地的一个仓库和 Github 上创建的一个仓库关联可以这样` git remote add origin https://github.com/Snailclimb/test.git `
@@ -164,7 +164,7 @@ Git 有三种状态,你的文件可能处于其中之一:
164164
165165### 远程仓库的移除与重命名
166166
167- - 将 test 重命名位 test1:` git remote rename test test1 `
167+ - 将 test 重命名为 test1:` git remote rename test test1 `
168168- 移除远程仓库 test1:` git remote rm test1 `
169169
170170### 查看提交历史
@@ -183,31 +183,30 @@ git log --author=bob
183183
184184有时候我们提交完了才发现漏掉了几个文件没有添加,或者提交信息写错了。 此时,可以运行带有 ` --amend ` 选项的提交命令尝试重新提交:
185185
186- ``` console
186+ ``` shell
187187git commit --amend
188188```
189189
190190取消暂存的文件
191191
192- ``` console
192+ ``` shell
193193git reset filename
194194```
195195
196196撤消对文件的修改:
197197
198- ```
198+ ``` shell
199199git checkout -- filename
200200```
201201
202202假如你想丢弃你在本地的所有改动与提交,可以到服务器上获取最新的版本历史,并将你本地主分支指向它:
203203
204- ```
204+ ``` shell
205205git fetch origin
206206git reset --hard origin/master
207207```
208208
209209
210-
211210### 分支
212211
213212分支是用来将特性开发绝缘开来的。在你创建仓库的时候,* master* 是“默认的”分支。在其他分支上进行开发,完成后再将它们合并到主分支上。
@@ -216,13 +215,13 @@ git reset --hard origin/master
216215
217216创建一个名字叫做 test 的分支
218217
219- ``` console
218+ ``` shell
220219git branch test
221220```
222221
223222切换当前分支到 test(当你切换分支的时候,Git 会重置你的工作目录,使其看起来像回到了你在那个分支上最后一次提交的样子。 Git 会自动添加、删除、修改文件以确保此时你的工作目录和这个分支最后一次提交时的样子一模一样)
224223
225- ``` console
224+ ``` shell
226225git checkout test
227226```
228227
@@ -232,39 +231,39 @@ git checkout test
232231
233232你也可以直接这样创建分支并切换过去(上面两条命令的合写)
234233
235- ``` console
234+ ``` shell
236235git checkout -b feature_x
237236```
238237
239238切换到主分支
240239
241- ```
240+ ``` shell
242241git checkout master
243242```
244243
245244合并分支(可能会有冲突)
246245
247- ``` java
246+ ``` shell
248247 git merge test
249248```
250249
251250把新建的分支删掉
252251
253- ```
252+ ``` shell
254253git branch -d feature_x
255254```
256255
257256将分支推送到远端仓库(推送成功后其他人可见):
258257
259- ```
260- git push origin
258+ ``` shell
259+ git push origin
261260```
262261
263262## 推荐
264263
265264** 在线演示学习工具:**
266265
267- 「补充,来自[ issue729] ( https://github.com/Snailclimb/JavaGuide/issues/729 ) 」Learn Git Branching https://oschina.gitee.io/learn-git-branching/ 。该网站可以方便的演示基本的git操作,讲解得明明白白。每一个基本命令的作用和结果。
266+ 「补充,来自[ issue729] ( https://github.com/Snailclimb/JavaGuide/issues/729 ) 」Learn Git Branching https://oschina.gitee.io/learn-git-branching/。该网站可以方便的演示基本的git操作,讲解得明明白白。每一个基本命令的作用和结果。
268267
269268** 推荐阅读:**
270269
0 commit comments