# generate initial key
gpg --full-generate-key
gpg --list-secret-keys --keyid-format LONG # get ID (sec)
gpg --armor --export 3AA5C34371567BD2 # get pubkey
# add identity
gpg --edit-key 3AA5C34371567BD2
$ gpg> adduid
gpg --armor --export 3AA5C34371567BD2 # get pubkey again
$ gpg --export-secret-keys --armor 3AA5C34371567BD2 > pgp_secret.asc
$ gpg --export-ownertrust > pgp_trustdb_backup.txt
$ gpg —-import pgp_secret.asc
# If you get a strange error, also try
$ cat pgp_secret.asc | gpg --with-colons --import
# Will delete the existing trust database.
$ rm ~/.gnupg/trustdb.gpg
$ gpg --import-ownertrust < pgp_trustdb_backup.txt
# Trust your own key if not restoring trust database
$ gpg --edit-key 3AA5C34371567BD2
$ gpg> trust # choose "ultimate" or other trust level
$ gpg> save # save the changes
$ git config --global user.signingkey 3AA5C34371567BD2
# Auto-sign all commits globaly
$ git config --global commit.gpgsign true