Skip to content

Commit f3a2b82

Browse files
webmaniakmadx
authored andcommitted
Updated documentation about the GPG feature + minor enhancements
1 parent 865fda9 commit f3a2b82

File tree

2 files changed

+71
-7
lines changed

2 files changed

+71
-7
lines changed

GPG_SETUP.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
Setting up GPG for Git
2+
======================
3+
4+
If you want to use the GPG feature within `git`, there are a few steps for you to follow. These steps are described at many places, but a reminder never hurts.
5+
6+
Generating a new key
7+
--------------------
8+
9+
If you don't have any GPG key yet, you can generate it from a terminal (or Git Bash for Windows) using the following command:
10+
11+
$ gpg --gen-key
12+
13+
Follow the wizard and answer the questions about your identity (name, email address). It's advised to leave the default values, but if you wish extra security, chose a keysize of 4096.
14+
Once generated, you can export your keys via the following commands:
15+
16+
$ gpg --export --armor user@example.com > public.asc
17+
$ gpg --export-secret-keys -o private.gpg user@example.com
18+
$ gpg --output revokecert.asc --gen-revoke user@example.com
19+
20+
This will output three different files:
21+
22+
* `public.asc` contains your public key. Copy its content and [send it to GitHub](https://help.github.com/articles/adding-a-new-gpg-key-to-your-github-account/) or any other git service you use
23+
* `private.gpg` contains your private key. This one needs to be put on a safe place. You must **avoid publishing somewhere at all cost**
24+
* `revokecert.asc` contains a certification for revoking your keys. Simply put, you'll need it only if your keys gets compromised
25+
26+
Importing an existing key
27+
-------------------------
28+
29+
If you already have a GPG key that you wish to use for signing your commits, you must first import it to your system (if it's not present).
30+
31+
Check which keys you already have:
32+
33+
$ gpg --list-secret-keys
34+
35+
If your key is not in there, you can import it:
36+
37+
$ gpg --import myprivatekey.gpg
38+
39+
Check it has been imported:
40+
41+
$ gpg --list-secret-keys --keyid-format LONG
42+
43+
Copy the ID of your private key and register this key in `git-identity`:
44+
45+
$ git identity --define-gpg <identity name> <gpgkeyid>
46+
47+
Additional resources
48+
--------------------
49+
50+
Here are some interesting resources you might want to read if you wish to go deeper on GPG with git:
51+
52+
* [Generating a new GPG key](https://help.github.com/articles/generating-a-new-gpg-key/)
53+
* [Adding a new GPG key to your GitHub account](https://help.github.com/articles/adding-a-new-gpg-key-to-your-github-account/)
54+
* [Installing your GPG key in git](https://help.github.com/articles/telling-git-about-your-gpg-key/)

README.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ will pick it up and make it available as `git identity`.
1616

1717
$ ln -s git-identity ~/bin/git-identity
1818

19-
Then you may setup a default identity with the following command (see Usage for
20-
more information):
19+
Under Windows, go to System > Advanced System Parameters > Environment Variable. Find the "Path" entry under *system variables* and add the path to where you downloaded `git-identity`.
20+
21+
Then you may setup a default identity with the following command (see Usage for more information):
2122

2223
$ git identity --define default Me me@example.org
2324

@@ -29,6 +30,15 @@ To get zsh completion, move the `git-identity.zsh-completion` file to a location
2930
Usage
3031
-----
3132

33+
Add an identity:
34+
35+
$ git identity --define <identity name> <user name> <user email>
36+
37+
Add a GPG key to the identity (see GPG specific information below)
38+
39+
$ git identity --define-gpg <identity name> <gpgkeyid>
40+
Added GPG key DA221397A6FF5EZZ to [default] user <user@example.org> (GPG key: DA221397A6FF5EZZ)
41+
3242
Print the current identity:
3343

3444
$ git identity
@@ -39,7 +49,7 @@ Change identity:
3949
$ git identity user2
4050
Using identity: [default2] user2 <user2@example.org>
4151

42-
Listing identities:
52+
List all identities:
4353

4454
$ git identity --list
4555
Available identities:
@@ -52,10 +62,6 @@ Listing raw identities:
5262
default
5363
default2
5464

55-
Adding an identity:
56-
57-
$ git identity --define <identity name> <user name> <user email>
58-
5965
Deleting an identity:
6066

6167
$ git identity --remove <identity name>
@@ -65,3 +71,7 @@ Printing the raw identity (for use in scripts)
6571
$ git identity --print
6672
$ git identity --print <identity name>
6773

74+
Setting up GPG
75+
--------------
76+
77+
More information about how to use GPG with `git-identity` may be found in [GPG_SETUP.md](GPG_SETUP.md)

0 commit comments

Comments
 (0)