如何在Git中使用GPG

开篇之前,先给大伙看点东西

GitHub Gpg 认证

是不是很想要?你找对地方了!


下面是教程:

在 “开始”菜单 打开Git Bash

输入 gpg --gen-key

显示如下

$ gpg --gen-key

gpg (GnuPG) 2.2.13-unknown; Copyright (C) 2019 Free Software Foundation, Inc.

This is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law.

Note: Use "gpg --full-generate-key" for a full featured key generation dialog.

GnuPG needs to construct a user ID to identify your key.

Real name: 这里填GitHub Username

Email address: 这里填GitHub email address private

You selected this USER-ID: # 生成部分

    "你的GitHub Username <你的GitHub email address private>"

Change (N)ame, (E)mail, or (O)kay/(Q)uit? O

We need to generate a lot of random bytes. It is a good idea to perform

some other action (type on the keyboard, move the mouse, utilize the

disks) during the prime generation; this gives the random number

generator a better chance to gain enough entropy.

We need to generate a lot of random bytes. It is a good idea to perform

some other action (type on the keyboard, move the mouse, utilize the

disks) during the prime generation; this gives the random number

generator a better chance to gain enough entropy.

gpg: key 2E728412D609DBC4 marked as ultimately trusted

gpg: revocation certificate stored as '/c/Users/Administrator/.gnupg/openpgp-revocs.d/D511141C8CE2FF942A4DFA542E728412D609DBC4.rev'

public and secret key created and signed.

pub  rsa2048 2019-06-01 [SC] [expires: 2021-05-31]

      D511141C8CE2FF942A4DFA542E728412D609DBC4

uid                        [ultimate] xxxxx <xxxx@xxxx.com>

sub  rsa2048 2019-06-01 [E] [expires: 2021-05-31]

查看密钥

# 输入 gpg --list-keys --keyid-format SHORT
gpg --list-keys --keyid-format SHORT

# 返回内容如下

pub  rsa2048/D609DBC4 2019-06-01 [SC] [expires: 2021-05-31]

      D511141C8CE2FF942A4DFA542E728412D609DBC4

uid        [ultimate] xxxxx <xxxx@xxxx.com>

发布密钥

# 输入
gpg --send-key 你的密钥
# 你的密钥就是rsa2048/xxxxxxx中的xxxxxxx

github设置GPG key

拷贝上面得到的公钥到github账号中,注意:格式如:

输入 gpg --armor --export xxxxxx

显示出来的就是像下面的内容

开头:

-----BEGIN PGP PUBLIC KEY BLOCK-----

结尾:

-----END PGP PUBLIC KEY BLOCK-----
你只需将其添加到代码GitHub的gpg key中就可以了


配置git

git config --global user.signingkey 你的GPG key ID
# 例如:
# git config --global user.signingkey D609DBC4

git config commit.gpgsign true

git config --global commit.gpgsign true

配置完成


一些感受

在我完成了GPG配置后,我感觉还是比较麻烦的,因为每commit一次就要输一次密码。别的我倒没有发觉什么不好的。但vs code的git管理对gpg好像不怎么友好。

与转载相关的事情

在这里插入图片描述
在这里插入图片描述
我从我的账号转载过来,所以现在我申请了CSDN的搬家搬家申请
这是搬家声明
搬家声明

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Mryan2005

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值