https://blog.51cto.com/u_12772149/2609241 https://bbs.huaweicloud.com/blogs/290331 https://spwo.notion.site/GitHub-6b1e1d57f52c4664bff61cadb3f9cb8d#d50ec6892bf545f6bb8efea626059123 https://stackoverflow.com/questions/61067967/git-gpg-failed-to-sign-the-data-in-visual-studio-code

gpg --gen-key
gpg -K # 列出私钥
gpg -k # 列出公钥
gpg --import public-file.key
gpg --list-secret-keys

gpg --armor --output public-key.txt --export 63ECA75D
gpg -a -o private-file.key --export-secret-keys 63ECA75D
gpg --armor --export 383F63B363ECA75D
# 为了可以输入密码,加入shell的配置文件
export GPG_TTY=$(tty)



git config --global user.signingkey 63ECA75D
git config --global commit.gpgsign true
git config --global user.name "thredreams"
git config --global user.email "1220474743@qq.com"
git config --global -l
git config  -l

git remote add origin git@github.com:envoyproxy/gateway.git
git remote remove myEnvoyGateway
git remote add  myEnvoyGateway git@github.com:thredreams/gateway.git
# 查看仓库
git remote -v

git log --show-signature


#如果gpg使用错误
git config --global gpg.program /usr/bin/gpg
git config --global gpg.program gpg1

#git

安装gpg

# Centos
yum install gnupg
# Ubuntu
apt install gpg
# windows 一般用不上实在要用,可以用git自带的,应该在Git的安装目录的Git/usr/bin目录下
# 或者使用WSL,在WSL环境中安装,
# 或者真要装,还可以使用scoop安装

GPG 导致的You need a passphrase to unlock the secret key for user 处理方法

可以通过

gpg -s tmp_file_name

来打开密码输入页面, 输入密码后再继续commit 即可。tmp_file_name 这个文件可以不存在, 就是给输入密码一个机会。

git commit -S -m "comment for new commit"
git commit -s -m "注意下面只是在commit message里添加内容"

上次提交没有签名


 # 为上次提交签名,需要输入密码
 git commit --amend -S -m "add -e to echo command" -s
 # 查看签名结果
 git log
 # 将本地仓库强制覆盖远程仓库
 git push orgin -f
 

gpg: skipped “383F63B363ECA75D”: No secret key

git 默认使用的是 Git\usr\bin 目录下的 gpg. exe、使用 everything 搜索一下有几个 gpg. exe,然后使用上面说的内容修改一下 git 使用的 gpg 程序就好了。