Skip to content

Commit b2911a3

Browse files
committed
move signing features to tools chapter
I feel like they’re too complicated and too often unused to be in Chapter 2. Plus now we have signed commits.
1 parent b64476c commit b2911a3

File tree

2 files changed

+85
-79
lines changed

2 files changed

+85
-79
lines changed

book/02-git-basics/1-git-basics.asc

Lines changed: 4 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,9 @@ v1.8.5.5
12951295
==== Creating Tags
12961296

12971297
Git uses two main types of tags: lightweight and annotated.
1298+
12981299
A lightweight tag is very much like a branch that doesn’t change – it’s just a pointer to a specific commit.
1300+
12991301
Annotated tags, however, are stored as full objects in the Git database.
13001302
They’re checksummed; contain the tagger name, e-mail, and date; have a tagging message; and can be signed and verified with GNU Privacy Guard (GPG).
13011303
It’s generally recommended that you create annotated tags so you can have all this information; but if you want a temporary tag or for some reason don’t want to keep the other information, lightweight tags are available too.
@@ -1337,52 +1339,6 @@ Date: Mon Mar 17 21:52:11 2008 -0700
13371339

13381340
That shows the tagger information, the date the commit was tagged, and the annotation message before showing the commit information.
13391341

1340-
==== Signed Tags
1341-
1342-
You can also sign your tags with GPG, assuming you have a private key.
1343-
All you have to do is use `-s` instead of `-a`:
1344-
1345-
[source,shell]
1346-
----
1347-
$ git tag -s v1.5 -m 'my signed 1.5 tag'
1348-
1349-
You need a passphrase to unlock the secret key for
1350-
user: "Ben Straub <[email protected]>"
1351-
2048-bit RSA key, ID 800430EB, created 2014-05-04
1352-
1353-
----
1354-
1355-
If you run `git show` on that tag, you can see your GPG signature attached to it:
1356-
1357-
[source,shell]
1358-
--------
1359-
$ git show v1.5
1360-
tag v1.5
1361-
Tagger: Ben Straub <[email protected]>
1362-
Date: Sat May 3 20:29:41 2014 -0700
1363-
1364-
my signed 1.5 tag
1365-
-----BEGIN PGP SIGNATURE-----
1366-
Version: GnuPG v1
1367-
1368-
iQEcBAABAgAGBQJTZbQlAAoJEF0+sviABDDrZbQH/09PfE51KPVPlanr6q1v4/Ut
1369-
LQxfojUWiLQdg2ESJItkcuweYg+kc3HCyFejeDIBw9dpXt00rY26p05qrpnG+85b
1370-
hM1/PswpPLuBSr+oCIDj5GMC2r2iEKsfv2fJbNW8iWAXVLoWZRF8B0MfqX/YTMbm
1371-
ecorc4iXzQu7tupRihslbNkfvfciMnSDeSvzCpWAHl7h8Wj6hhqePmLm9lAYqnKp
1372-
8S5B/1SSQuEAjRZgI4IexpZoeKGVDptPHxLLS38fozsyi0QyDyzEgJxcJQVMXxVi
1373-
RUysgqjcpT8+iQM1PblGfHR4XAhuOqN5Fx06PSaFZhqvWFezJ28/CLyX5q+oIVk=
1374-
=EFTF
1375-
-----END PGP SIGNATURE-----
1376-
1377-
commit ca82a6dff817ec66f44342007202690a93763949
1378-
Author: Scott Chacon <[email protected]>
1379-
Date: Mon Mar 17 21:52:11 2008 -0700
1380-
1381-
changed the verison number
1382-
--------
1383-
1384-
A bit later, you’ll learn how to verify signed tags.
1385-
13861342
==== Lightweight Tags
13871343

13881344
Another way to tag commits is with a lightweight tag.
@@ -1413,38 +1369,6 @@ Date: Mon Mar 17 21:52:11 2008 -0700
14131369
changed the verison number
14141370
----
14151371

1416-
==== Verifying Tags
1417-
1418-
To verify a signed tag, you use `git tag -v [tag-name]`.
1419-
This command uses GPG to verify the signature.
1420-
You need the signer’s public key in your keyring for this to work properly:
1421-
1422-
[source,shell]
1423-
----
1424-
$ git tag -v v1.4.2.1
1425-
object 883653babd8ee7ea23e6a5c392bb739348b1eb61
1426-
type commit
1427-
tag v1.4.2.1
1428-
tagger Junio C Hamano <[email protected]> 1158138501 -0700
1429-
1430-
GIT 1.4.2.1
1431-
1432-
Minor fixes since 1.4.2, including git-mv and git-http with alternates.
1433-
gpg: Signature made Wed Sep 13 02:08:25 2006 PDT using DSA key ID F3119B9A
1434-
gpg: Good signature from "Junio C Hamano <[email protected]>"
1435-
gpg: aka "[jpeg image of size 1513]"
1436-
Primary key fingerprint: 3565 2A26 2040 E066 C9A7 4A7D C0C6 D9A4 F311 9B9A
1437-
----
1438-
1439-
If you don’t have the signer’s public key, you get something like this instead:
1440-
1441-
[source,shell]
1442-
----
1443-
gpg: Signature made Wed Sep 13 02:08:25 2006 PDT using DSA key ID F3119B9A
1444-
gpg: Can't check signature: public key not found
1445-
error: could not verify the tag 'v1.4.2.1'
1446-
----
1447-
14481372
==== Tagging Later
14491373

14501374
You can also tag commits after you’ve moved past them.
@@ -1534,12 +1458,13 @@ To [email protected]:schacon/simplegit.git
15341458

15351459
Now, when someone else clones or pulls from your repository, they will get all your tags as well.
15361460

1461+
15371462
=== Git Aliases
15381463

15391464
Before we finish this chapter on basic Git, there's just one little tip that can make your Git experience simpler, easier, and more familiar: aliases.
15401465
We won’t refer to them or assume you’ve used them later in the book, but you should probably know how to use them.
15411466

1542-
Git doesn’t infer your command if you type it in partially.
1467+
Git doesn’t automatically infer your command if you type it in partially.
15431468
If you don’t want to type the entire text of each of the Git commands, you can easily set up an alias for each command using `git config`.
15441469
Here are a couple of examples you may want to set up:
15451470

book/07-git-tools/1-git-tools.asc

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,87 @@ If you want an easier way to test the stashed changes again, you can run `git st
603603

604604
This is a nice shortcut to recover stashed work easily and work on it in a new branch.
605605

606+
607+
=== Signing Your Work
608+
609+
Git is cryptographically secure, but it's not foolproof. If you're taking work from others on the internet and want to verify that commits are actually from a trusted source, Git has a few ways to sign and verify work using GPG.
610+
611+
==== Signed Tags
612+
613+
You can also sign your tags with GPG, assuming you have a private key.
614+
All you have to do is use `-s` instead of `-a`:
615+
616+
[source,shell]
617+
----
618+
$ git tag -s v1.5 -m 'my signed 1.5 tag'
619+
620+
You need a passphrase to unlock the secret key for
621+
user: "Ben Straub <[email protected]>"
622+
2048-bit RSA key, ID 800430EB, created 2014-05-04
623+
624+
----
625+
626+
If you run `git show` on that tag, you can see your GPG signature attached to it:
627+
628+
[source,shell]
629+
--------
630+
$ git show v1.5
631+
tag v1.5
632+
Tagger: Ben Straub <[email protected]>
633+
Date: Sat May 3 20:29:41 2014 -0700
634+
635+
my signed 1.5 tag
636+
-----BEGIN PGP SIGNATURE-----
637+
Version: GnuPG v1
638+
639+
iQEcBAABAgAGBQJTZbQlAAoJEF0+sviABDDrZbQH/09PfE51KPVPlanr6q1v4/Ut
640+
LQxfojUWiLQdg2ESJItkcuweYg+kc3HCyFejeDIBw9dpXt00rY26p05qrpnG+85b
641+
hM1/PswpPLuBSr+oCIDj5GMC2r2iEKsfv2fJbNW8iWAXVLoWZRF8B0MfqX/YTMbm
642+
ecorc4iXzQu7tupRihslbNkfvfciMnSDeSvzCpWAHl7h8Wj6hhqePmLm9lAYqnKp
643+
8S5B/1SSQuEAjRZgI4IexpZoeKGVDptPHxLLS38fozsyi0QyDyzEgJxcJQVMXxVi
644+
RUysgqjcpT8+iQM1PblGfHR4XAhuOqN5Fx06PSaFZhqvWFezJ28/CLyX5q+oIVk=
645+
=EFTF
646+
-----END PGP SIGNATURE-----
647+
648+
commit ca82a6dff817ec66f44342007202690a93763949
649+
Author: Scott Chacon <[email protected]>
650+
Date: Mon Mar 17 21:52:11 2008 -0700
651+
652+
changed the verison number
653+
--------
654+
655+
==== Verifying Tags
656+
657+
To verify a signed tag, you use `git tag -v [tag-name]`.
658+
This command uses GPG to verify the signature.
659+
You need the signer’s public key in your keyring for this to work properly:
660+
661+
[source,shell]
662+
----
663+
$ git tag -v v1.4.2.1
664+
object 883653babd8ee7ea23e6a5c392bb739348b1eb61
665+
type commit
666+
tag v1.4.2.1
667+
tagger Junio C Hamano <[email protected]> 1158138501 -0700
668+
669+
GIT 1.4.2.1
670+
671+
Minor fixes since 1.4.2, including git-mv and git-http with alternates.
672+
gpg: Signature made Wed Sep 13 02:08:25 2006 PDT using DSA key ID F3119B9A
673+
gpg: Good signature from "Junio C Hamano <[email protected]>"
674+
gpg: aka "[jpeg image of size 1513]"
675+
Primary key fingerprint: 3565 2A26 2040 E066 C9A7 4A7D C0C6 D9A4 F311 9B9A
676+
----
677+
678+
If you don’t have the signer’s public key, you get something like this instead:
679+
680+
[source,shell]
681+
----
682+
gpg: Signature made Wed Sep 13 02:08:25 2006 PDT using DSA key ID F3119B9A
683+
gpg: Can't check signature: public key not found
684+
error: could not verify the tag 'v1.4.2.1'
685+
----
686+
606687
=== Searching
607688

608689
=== Rewriting History

0 commit comments

Comments
 (0)