0

Git Initialization | TripleZ's Blog

 2 years ago
source link: https://blog.triplez.cn/posts/git-initialization/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
  • 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
/home/triplez/.gnupg/pubring.kbx
--------------------------------
sec   rsa4096/96B4168C3D454E11 2018-11-28 [SC]
      6B0B48B063F8F592CE9006DE96B4168C3D454E11
uid                 [ultimate] Zhenzhen Zhao (my gpg) <[email protected]>
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

References#


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

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK