Skip to content

Commit 3f8b75b

Browse files
committed
Fix console coloring in maintaining.asc
1 parent a33d55f commit 3f8b75b

File tree

1 file changed

+55
-54
lines changed

1 file changed

+55
-54
lines changed

book/05-distributed-git/sections/maintaining.asc

Lines changed: 55 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ The maintainer of the Git project tends to namespace these branches as well –
1515
As you'll remember, you can create the branch based off your master branch like this:
1616

1717
[source,console]
18-
-----
18+
----
1919
$ git branch sc/ruby_client master
20-
-----
20+
----
2121

2222
Or, if you want to also switch to it immediately, you can use the `checkout -b` option:
2323

2424
[source,console]
25-
-----
25+
----
2626
$ git checkout -b sc/ruby_client master
27-
-----
27+
----
2828

2929
Now you're ready to add your contributed work into this topic branch and determine if you want to merge it into your longer-term branches.
3030

@@ -42,9 +42,9 @@ If you received the patch from someone who generated it with the `git diff` or a
4242
Assuming you saved the patch at `/tmp/patch-ruby-client.patch`, you can apply the patch like this:
4343

4444
[source,console]
45-
-----
45+
----
4646
$ git apply /tmp/patch-ruby-client.patch
47-
-----
47+
----
4848

4949
This modifies the files in your working directory.
5050
It's almost identical to running a `patch -p1` command to apply the patch, although it's more paranoid and accepts fewer fuzzy matches than patch.
@@ -56,11 +56,11 @@ It won't create a commit for you – after running it, you must stage and commit
5656
You can also use git apply to see if a patch applies cleanly before you try actually applying it – you can run `git apply --check` with the patch:
5757

5858
[source,console]
59-
-----
59+
----
6060
$ git apply --check 0001-seeing-if-this-helps-the-gem.patch
6161
error: patch failed: ticgit.gemspec:1
6262
error: ticgit.gemspec: patch does not apply
63-
-----
63+
----
6464

6565
If there is no output, then the patch should apply cleanly.
6666
This command also exits with a non-zero status if the check fails, so you can use it in scripts if you want.
@@ -78,14 +78,14 @@ Technically, `git am` is built to read an mbox file, which is a simple, plain-te
7878
It looks something like this:
7979

8080
[source,console]
81-
-----
81+
----
8282
From 330090432754092d704da8e76ca5c05c198e71a8 Mon Sep 17 00:00:00 2001
8383
From: Jessica Smith <[email protected]>
8484
Date: Sun, 6 Apr 2008 10:17:23 -0700
8585
Subject: [PATCH 1/2] add limit to log function
8686
8787
Limit log functionality to the first 20
88-
-----
88+
----
8989

9090
This is the beginning of the output of the format-patch command that you saw in the previous section.
9191
This is also a valid mbox email format.
@@ -95,16 +95,17 @@ If you run a mail client that can save several emails out in mbox format, you ca
9595
However, if someone uploaded a patch file generated via `format-patch` to a ticketing system or something similar, you can save the file locally and then pass that file saved on your disk to `git am` to apply it:
9696

9797
[source,console]
98-
-----
98+
----
9999
$ git am 0001-limit-log-function.patch
100100
Applying: add limit to log function
101-
-----
101+
----
102102

103103
You can see that it applied cleanly and automatically created the new commit for you.
104104
The author information is taken from the email's `From` and `Date` headers, and the message of the commit is taken from the `Subject` and body (before the patch) of the email.
105105
For example, if this patch was applied from the mbox example above, the commit generated would look something like this:
106106

107-
-----
107+
[source,console]
108+
----
108109
$ git log --pretty=fuller -1
109110
commit 6c5e70b984a60b3cecd395edd5b48a7575bf58e0
110111
Author: Jessica Smith <[email protected]>
@@ -115,7 +116,7 @@ CommitDate: Thu Apr 9 09:19:06 2009 -0700
115116
add limit to log function
116117
117118
Limit log functionality to the first 20
118-
-----
119+
----
119120

120121
The `Commit` information indicates the person who applied the patch and the time it was applied.
121122
The `Author` information is the individual who originally created the patch and when it was originally created.
@@ -125,7 +126,7 @@ Perhaps your main branch has diverged too far from the branch the patch was buil
125126
In that case, the `git am` process will fail and ask you what you want to do:
126127

127128
[source,console]
128-
-----
129+
----
129130
$ git am 0001-seeing-if-this-helps-the-gem.patch
130131
Applying: seeing if this helps the gem
131132
error: patch failed: ticgit.gemspec:1
@@ -134,48 +135,48 @@ Patch failed at 0001.
134135
When you have resolved this problem run "git am --resolved".
135136
If you would prefer to skip this patch, instead run "git am --skip".
136137
To restore the original branch and stop patching run "git am --abort".
137-
-----
138+
----
138139

139140
This command puts conflict markers in any files it has issues with, much like a conflicted merge or rebase operation.
140141
You solve this issue much the same way – edit the file to resolve the conflict, stage the new file, and then run `git am --resolved` to continue to the next patch:
141142

142143
[source,console]
143-
-----
144+
----
144145
$ (fix the file)
145146
$ git add ticgit.gemspec
146147
$ git am --resolved
147148
Applying: seeing if this helps the gem
148-
-----
149+
----
149150

150151
If you want Git to try a bit more intelligently to resolve the conflict, you can pass a `-3` option to it, which makes Git attempt a three-way merge.
151152
This option isn't on by default because it doesn't work if the commit the patch says it was based on isn't in your repository.
152153
If you do have that commit – if the patch was based on a public commit – then the `-3` option is generally much smarter about applying a conflicting patch:
153154

154155
[source,console]
155-
-----
156+
----
156157
$ git am -3 0001-seeing-if-this-helps-the-gem.patch
157158
Applying: seeing if this helps the gem
158159
error: patch failed: ticgit.gemspec:1
159160
error: ticgit.gemspec: patch does not apply
160161
Using index info to reconstruct a base tree...
161162
Falling back to patching base and 3-way merge...
162163
No changes -- Patch already applied.
163-
-----
164+
----
164165

165166
In this case, this patch had already been applied.
166167
Without the `-3` option, it looks like a conflict.
167168

168169
If you're applying a number of patches from an mbox, you can also run the `am` command in interactive mode, which stops at each patch it finds and asks if you want to apply it:
169170

170171
[source,console]
171-
-----
172+
----
172173
$ git am -3 -i mbox
173174
Commit Body is:
174175
--------------------------
175176
seeing if this helps the gem
176177
--------------------------
177178
Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all
178-
-----
179+
----
179180

180181
This is nice if you have a number of patches saved, because you can view the patch first if you don't remember what it is, or not apply the patch if you've already done so.
181182

@@ -190,11 +191,11 @@ If your contribution came from a Git user who set up their own repository, pushe
190191
For instance, if Jessica sends you an email saying that she has a great new feature in the `ruby-client` branch of her repository, you can test it by adding the remote and checking out that branch locally:
191192

192193
[source,console]
193-
-----
194+
----
194195
$ git remote add jessica git://github.com/jessica/myproject.git
195196
$ git fetch jessica
196197
$ git checkout -b rubyclient jessica/ruby-client
197-
-----
198+
----
198199

199200
If she emails you again later with another branch containing another great feature, you can fetch and check out because you already have the remote setup.
200201

@@ -210,12 +211,12 @@ If you aren't working with a person consistently but still want to pull from the
210211
This does a one-time pull and doesn't save the URL as a remote reference:
211212

212213
[source,console]
213-
-----
214+
----
214215
$ git pull https://github.com/onetimeguy/project
215216
From https://github.com/onetimeguy/project
216217
* branch HEAD -> FETCH_HEAD
217218
Merge made by recursive.
218-
-----
219+
----
219220

220221
[[_what_is_introduced]]
221222
==== Determining What Is Introduced
@@ -231,7 +232,7 @@ This does the same thing as the `master..contrib` format that we used earlier.
231232
For example, if your contributor sends you two patches and you create a branch called `contrib` and applied those patches there, you can run this:
232233

233234
[source,console]
234-
-----
235+
----
235236
$ git log contrib --not master
236237
commit 5b6235bd297351589efc4d73316f0a68d484f118
237238
Author: Scott Chacon <[email protected]>
@@ -244,17 +245,17 @@ Author: Scott Chacon <[email protected]>
244245
Date: Mon Oct 22 19:38:36 2008 -0700
245246
246247
updated the gemspec to hopefully work better
247-
-----
248+
----
248249

249250
To see what changes each commit introduces, remember that you can pass the `-p` option to `git log` and it will append the diff introduced to each commit.
250251

251252
To see a full diff of what would happen if you were to merge this topic branch with another branch, you may have to use a weird trick to get the correct results.
252253
You may think to run this:
253254

254255
[source,console]
255-
-----
256+
----
256257
$ git diff master
257-
-----
258+
----
258259

259260
This command gives you a diff, but it may be misleading.
260261
If your `master` branch has moved forward since you created the topic branch from it, then you'll get seemingly strange results.
@@ -269,19 +270,19 @@ You do that by having Git compare the last commit on your topic branch with the
269270
Technically, you can do that by explicitly figuring out the common ancestor and then running your diff on it:
270271

271272
[source,console]
272-
-----
273+
----
273274
$ git merge-base contrib master
274275
36c7dba2c95e6bbb78dfa822519ecfec6e1ca649
275276
$ git diff 36c7db
276-
-----
277+
----
277278

278279
However, that isn't convenient, so Git provides another shorthand for doing the same thing: the triple-dot syntax.
279280
In the context of the `diff` command, you can put three periods after another branch to do a `diff` between the last commit of the branch you're on and its common ancestor with another branch:
280281

281282
[source,console]
282-
-----
283+
----
283284
$ git diff master...contrib
284-
-----
285+
----
285286

286287
This command shows you only the work your current topic branch has introduced since its common ancestor with master.
287288
That is a very useful syntax to remember.
@@ -376,12 +377,12 @@ image::images/rebasing-1.png[Example history before a cherry-pick.]
376377
If you want to pull commit `e43a6` into your master branch, you can run
377378

378379
[source,console]
379-
-----
380+
----
380381
$ git cherry-pick e43a6fd3e94888d76779ad79fb568ed180e5fcdf
381382
Finished one cherry-pick.
382383
[master]: created a0a41a9: "More friendly message when locking the index fails."
383384
3 files changed, 17 insertions(+), 3 deletions(-)
384-
-----
385+
----
385386

386387
This pulls the same change introduced in `e43a6`, but you get a new commit SHA-1 value, because the date applied is different.
387388
Now your history looks like this:
@@ -423,49 +424,49 @@ You can create a new tag as discussed in <<_git_basics_chapter>>.
423424
If you decide to sign the tag as the maintainer, the tagging may look something like this:
424425

425426
[source,console]
426-
-----
427+
----
427428
$ git tag -s v1.5 -m 'my signed 1.5 tag'
428429
You need a passphrase to unlock the secret key for
429430
user: "Scott Chacon <[email protected]>"
430431
1024-bit DSA key, ID F721C45A, created 2009-02-09
431-
-----
432+
----
432433

433434
If you do sign your tags, you may have the problem of distributing the public PGP key used to sign your tags.
434435
The maintainer of the Git project has solved this issue by including their public key as a blob in the repository and then adding a tag that points directly to that content.
435436
To do this, you can figure out which key you want by running `gpg --list-keys`:
436437

437438
[source,console]
438-
-----
439+
----
439440
$ gpg --list-keys
440441
/Users/schacon/.gnupg/pubring.gpg
441442
---------------------------------
442443
pub 1024D/F721C45A 2009-02-09 [expires: 2010-02-09]
443444
uid Scott Chacon <[email protected]>
444445
sub 2048g/45D02282 2009-02-09 [expires: 2010-02-09]
445-
-----
446+
----
446447
447448
Then, you can directly import the key into the Git database by exporting it and piping that through `git hash-object`, which writes a new blob with those contents into Git and gives you back the SHA-1 of the blob:
448449
449450
[source,console]
450-
-----
451+
----
451452
$ gpg -a --export F721C45A | git hash-object -w --stdin
452453
659ef797d181633c87ec71ac3f9ba29fe5775b92
453-
-----
454+
----
454455
455456
Now that you have the contents of your key in Git, you can create a tag that points directly to it by specifying the new SHA-1 value that the `hash-object` command gave you:
456457
457458
[source,console]
458-
-----
459+
----
459460
$ git tag -a maintainer-pgp-pub 659ef797d181633c87ec71ac3f9ba29fe5775b92
460-
-----
461+
----
461462
462463
If you run `git push --tags`, the `maintainer-pgp-pub` tag will be shared with everyone.
463464
If anyone wants to verify a tag, they can directly import your PGP key by pulling the blob directly out of the database and importing it into GPG:
464465
465466
[source,console]
466-
-----
467+
----
467468
$ git show maintainer-pgp-pub | gpg --import
468-
-----
469+
----
469470
470471
They can use that key to verify all your signed tags.
471472
Also, if you include instructions in the tag message, running `git show <tag>` will let you give the end user more specific instructions about tag verification.
@@ -478,10 +479,10 @@ Because Git doesn't have monotonically increasing numbers like 'v123' or the equ
478479
Git gives you the name of the nearest tag with the number of commits on top of that tag and a partial SHA-1 value of the commit you're describing:
479480
480481
[source,console]
481-
-----
482+
----
482483
$ git describe master
483484
v1.6.2-rc1-20-g8c5b85c
484-
-----
485+
----
485486
486487
This way, you can export a snapshot or build and name it something understandable to people.
487488
In fact, if you build Git from source code cloned from the Git repository, `git --version` gives you something that looks like this.
@@ -500,19 +501,19 @@ One of the things you'll want to do is create an archive of the latest snapshot
500501
The command to do this is `git archive`:
501502
502503
[source,console]
503-
-----
504+
----
504505
$ git archive master --prefix='project/' | gzip > `git describe master`.tar.gz
505506
$ ls *.tar.gz
506507
v1.6.2-rc1-20-g8c5b85c.tar.gz
507-
-----
508+
----
508509
509510
If someone opens that tarball, they get the latest snapshot of your project under a project directory.
510511
You can also create a zip archive in much the same way, but by passing the `--format=zip` option to `git archive`:
511512
512513
[source,console]
513-
-----
514+
----
514515
$ git archive master --prefix='project/' --format=zip > `git describe master`.zip
515-
-----
516+
----
516517
517518
You now have a nice tarball and a zip archive of your project release that you can upload to your website or email to people.
518519
@@ -525,7 +526,7 @@ A nice way of quickly getting a sort of changelog of what has been added to your
525526
It summarizes all the commits in the range you give it; for example, the following gives you a summary of all the commits since your last release, if your last release was named v1.0.1:
526527
527528
[source,console]
528-
-----
529+
----
529530
$ git shortlog --no-merges master --not v1.0.1
530531
Chris Wanstrath (8):
531532
Add support for annotated tags to Grit::Tag
@@ -540,6 +541,6 @@ Tom Preston-Werner (4):
540541
dynamic version method
541542
Version bump to 1.0.2
542543
Regenerated gemspec for version 1.0.2
543-
-----
544+
----
544545
545546
You get a clean summary of all the commits since v1.0.1, grouped by author, that you can email to your list.

0 commit comments

Comments
 (0)