@@ -106,7 +106,9 @@ Changes not staged for commit:
106
106
----
107
107
108
108
文件 `CONTRIBUTING.md` 出现在 `Changes not staged for commit` 这行下面,说明已跟踪文件的内容发生了变化,但还没有放到暂存区。
109
- 要暂存这次更新,需要运行 `git add` 命令。这是个多功能命令:可以用它开始跟踪新文件,或者把已跟踪的文件放到暂存区,还能用于合并时把有冲突的文件标记为已解决状态等。将这个命令理解为“添加内容到下一次提交中”而不是“将一个文件添加到项目中”要更加合适。(((git commands, add)))
109
+ 要暂存这次更新,需要运行 `git add` 命令。
110
+ 这是个多功能命令:可以用它开始跟踪新文件,或者把已跟踪的文件放到暂存区,还能用于合并时把有冲突的文件标记为已解决状态等。
111
+ 将这个命令理解为“添加内容到下一次提交中”而不是“将一个文件添加到项目中”要更加合适。(((git commands, add)))
110
112
现在让我们运行 `git add` 将"CONTRIBUTING.md"放到暂存区,然后再看看 `git status` 的输出:
111
113
112
114
[source,console]
@@ -167,7 +169,9 @@ Changes to be committed:
167
169
168
170
==== 状态简览
169
171
170
- `git status` 命令的输出十分详细,但其用语有些繁琐。如果你使用 `git status -s` 命令或 `git status --short` 命令,你将得到一种更为紧凑的格式输出。运行 `git status -s` ,状态报告输出如下:
172
+ `git status` 命令的输出十分详细,但其用语有些繁琐。
173
+ 如果你使用 `git status -s` 命令或 `git status --short` 命令,你将得到一种更为紧凑的格式输出。
174
+ 运行 `git status -s` ,状态报告输出如下:
171
175
172
176
[source,console]
173
177
----
@@ -179,7 +183,10 @@ M lib/simplegit.rb
179
183
?? LICENSE.txt
180
184
----
181
185
182
- 新添加的未跟踪文件前面有 `??` 标记,新添加到暂存区中的文件前面有 `A` 标记。修改过的文件前面有 `M` 标记,你可能注意到了 `M` 有两个可以出现的位置,出现在右边的 `M` 表示该文件被修改了但是还没放入暂存区,出现在靠左边的 `M` 表示该文件被修改了并放入了暂存区。例如,上面的状态报告显示: `README` 文件在工作区被修改了但是还没有将修改后的文件放入暂存区,`lib/simplegit.rb` 文件被修改了并将修改后的文件放入了暂存区,而 `Rakefile` 在工作区被修改并提交到暂存区后又在工作区中被修改了,所以在暂存区和工作区都有该文件被修改了的记录。
186
+ 新添加的未跟踪文件前面有 `??` 标记,新添加到暂存区中的文件前面有 `A` 标记,修改过的文件前面有 `M` 标记。
187
+ 你可能注意到了 `M` 有两个可以出现的位置,出现在右边的 `M` 表示该文件被修改了但是还没放入暂存区,出现在靠左边的 `M` 表示该文件被修改了并放入了暂存区。
188
+ 例如,上面的状态报告显示: `README` 文件在工作区被修改了但是还没有将修改后的文件放入暂存区,`lib/simplegit.rb` 文件被修改了并将修改后的文件放入了暂存区。
189
+ 而 `Rakefile` 在工作区被修改并提交到暂存区后又在工作区中被修改了,所以在暂存区和工作区都有该文件被修改了的记录。
183
190
184
191
[[_ignoring]]
185
192
==== 忽略文件
@@ -205,7 +212,8 @@ $ cat .gitignore
205
212
206
213
* 所有空行或者以 `#` 开头的行都会被 Git 忽略。
207
214
* 可以使用标准的 glob 模式匹配。
208
- * 匹配模式以(`/`)结尾说明要忽略的是目录。
215
+ * 匹配模式可以以(`/`)开头防止递归。
216
+ * 匹配模式可以以(`/`)结尾指定目录。
209
217
* 要忽略指定模式以外的文件或目录,可以在模式前加上惊叹号(`!`)取反。
210
218
211
219
所谓的 glob 模式是指 shell 所使用的简化了的正则表达式。
@@ -222,7 +230,7 @@ $ cat .gitignore
222
230
# but do track lib.a, even though you're ignoring .a files above
223
231
!lib.a
224
232
225
- # only ignore the root TODO file, not subdir/TODO
233
+ # only ignore the TODO file in the current directory , not subdir/TODO
226
234
/TODO
227
235
228
236
# ignore all files in the build/ directory
@@ -231,8 +239,8 @@ build/
231
239
# ignore doc/notes.txt, but not doc/server/arch.txt
232
240
doc/*.txt
233
241
234
- # ignore all .txt files in the doc/ directory
235
- doc/**/*.txt
242
+ # ignore all .pdf files in the doc/ directory
243
+ doc/**/*.pdf
236
244
----
237
245
238
246
[TIP]
@@ -258,7 +266,7 @@ On branch master
258
266
Changes to be committed:
259
267
(use "git reset HEAD <file>..." to unstage)
260
268
261
- new file : README
269
+ modified : README
262
270
263
271
Changes not staged for commit:
264
272
(use "git add <file>..." to update what will be committed)
@@ -281,7 +289,7 @@ index 8ebb991..643e24f 100644
281
289
if we have to read the whole diff to figure out why you're contributing
282
290
in the first place, you're less likely to get feedback and have your change
283
291
-merged in.
284
- +merged in. Also, split your changes into comprehensive chunks if you patch is
292
+ +merged in. Also, split your changes into comprehensive chunks if your patch is
285
293
+longer than a dozen lines.
286
294
287
295
If you are starting to work on a particular area, feel free to submit a PR
@@ -308,12 +316,13 @@ index 0000000..03902a1
308
316
请注意,git diff 本身只显示尚未暂存的改动,而不是自上次提交以来所做的所有改动。
309
317
所以有时候你一下子暂存了所有更新过的文件后,运行 `git diff` 后却什么也没有,就是这个原因。
310
318
311
- 像之前说的,暂存 `CONTRIBUTING.md` 后再编辑,运行 `git status` 会看到暂存前后的两个版本,如果我们的环境(终端输出)看起来如下:
319
+ 像之前说的,暂存 `CONTRIBUTING.md` 后再编辑,运行 `git status` 会看到暂存前后的两个版本。
320
+ 如果我们的环境(终端输出)看起来如下:
312
321
313
322
[source,console]
314
323
----
315
324
$ git add CONTRIBUTING.md
316
- $ echo 'test line' >> CONTRIBUTING.md
325
+ $ echo '# test line' >> CONTRIBUTING.md
317
326
$ git status
318
327
On branch master
319
328
Changes to be committed:
@@ -358,18 +367,19 @@ index 8ebb991..643e24f 100644
358
367
if we have to read the whole diff to figure out why you're contributing
359
368
in the first place, you're less likely to get feedback and have your change
360
369
-merged in.
361
- +merged in. Also, split your changes into comprehensive chunks if you patch is
370
+ +merged in. Also, split your changes into comprehensive chunks if your patch is
362
371
+longer than a dozen lines.
363
372
364
373
If you are starting to work on a particular area, feel free to submit a PR
365
374
that highlights your work in progress (and note in the PR title that it's
366
375
----
367
376
368
- [[_git_difftool]]
369
377
[NOTE]
370
378
.Git Diff 的插件版本
371
379
====
372
- 在本书中,我们使用 `git diff` 来分析文件差异。但是,如果你喜欢通过图形化的方式或其它格式输出方式的话,可以使用 `git difftool` 命令来用 Araxis ,emerge 或 vimdiff 等软件输出 diff 分析结果。使用 `git difftool --tool-help` 命令来看你的系统支持哪些 Git Diff 插件。
380
+ 在本书中,我们使用 `git diff` 来分析文件差异。
381
+ 但是,如果你喜欢通过图形化的方式或其它格式输出方式的话,可以使用 `git difftool` 命令来用 Araxis ,emerge 或 vimdiff 等软件输出 diff 分析结果。
382
+ 使用 `git difftool --tool-help` 命令来看你的系统支持哪些 Git Diff 插件。
373
383
====
374
384
375
385
[[_committing_changes]]
0 commit comments