• Change Git default settings;
  • Use GPG key to sign the Git commits.

Step by step

$ git config --global core.editor "vim"

# config your identity
git config --global user.email "YOUR_EMAIL"
git config --global user.name "YOUR_NAME"

# enable gpg signed commit
git config --global commit.gpgsign true

# generate gpg key
## git >= 2.1.17
gpg --full-generate-key
# or gpg --gen-key
## git < 2.1.17
gpg --default-new-key-algo rsa4096 --gen-key

# check your key id
$ gpg --list-secret-keys --keyid-format LONG
gpg: checking the trustdb
gpg: marginals needed: 3  completes needed: 1  trust model: pgp
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
sec   rsa4096/96B4168C3D454E11 2018-11-28 [SC]
uid                 [ultimate] Zhenzhen Zhao (my gpg) <me@triplez.cn>
ssb   rsa4096/435B8EB04CBF8E8D 2018-11-28 [E]

gpg --armor --export 96B4168C3D454E11
# copy your GPG key, beginning with -----BEGIN PGP PUBLIC KEY BLOCK----- and ending with -----END PGP PUBLIC KEY BLOCK-----, then add it to the GitHub

# set user to sign with this gpg key
git config --global user.signingkey 96B4168C3D454E11


本作品采用知识共享署名-相同方式共享 4.0 国际许可协议进行许可。