前言

由于工作需要,需要使用 Windows ,在 Windows 中开发始终没有那么方便。最近在用 Git 提交代码时想用 GPG 进行签名,于是就下载了 Gpg4win

安装好之后,在 Git Bash 中查看有没有配置好,于是输入 where gpg ,得到如下结果

1
2
3
$ where gpg
C:\Program Files\Git\usr\bin\gpg.exe
C:\Program Files (x86)\GnuPG\bin\gpg.exe

定睛一看, Git 目录下居然有 gpg

配置环境变量

既然 Git 自带了 GPG ,那么久没有必要再额外安装了,我们只需要把其加入环境变量中就可以在 cmd 中使用了。

除了 gpg 之外,我还在 C:\Program Files\Git\usr\bin 中发现了其它一些常用的命令,比如 chmodchown 等等,下面列出了一部分。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
bunzip2.exe*                    msys-kdc-2.dll*
bzcat.exe*                      msys-krb5-26.dll*
bzcmp*                          msys-ksba-8.dll*
bzdiff*                         msys-lz4-1.dll*
bzegrep*                        msys-lzma-5.dll*
bzfgrep*                        msys-magic-1.dll*
bzgrep*                         msys-menuw6.dll*
bzip2.exe*                      msys-metalink-3.dll*
bzip2recover.exe*               msys-mpfr-6.dll*
bzless*                         msys-ncurses++w6.dll*
bzmore*                         msys-ncursesw6.dll*
c_rehash*                       msys-nettle-8.dll*
captoinfo.exe*                  msys-nghttp2-14.dll*
cat.exe*                        msys-npth-0.dll*
chattr.exe*                     msys-p11-kit-0.dll*
chcon.exe*                      msys-panelw6.dll*
chgrp.exe*                      msys-pcre-1.dll*
chmod.exe*                      msys-pcre2-8-0.dll*
chown.exe*                      msys-perl5_30.dll*
chroot.exe*                     msys-psl-5.dll*
cksum.exe*                      msys-readline8.dll*
clear.exe*                      msys-roken-18.dll*
cmp.exe*                        msys-sasl2-3.dll*
column.exe*                     msys-serf-1-0.dll*
comm.exe*                       msys-sl-0.dll*
core_perl/                      msys-smartcols-1.dll*
cp.exe*                         msys-sqlite3-0.dll*
csplit.exe*                     msys-ssh2-1.dll*
cut.exe*                        msys-ssl-1.1.dll*
cygcheck.exe*                   msys-svn_delta-1-0.dll*
cygpath.exe*                    msys-svn_diff-1-0.dll*
cygwin-console-helper.exe*      msys-svn_fs_fs-1-0.dll*
dir.exe*                        msys-svn_wc-1-0.dll*
dircolors.exe*                  msys-tasn1-6.dll*
dirmngr.exe*                    msys-ticw6.dll*
dirmngr-client.exe*             msys-unistring-2.dll*
dirname.exe*                    msys-uuid-1.dll*
docx2txt*                       msys-wind-0.dll*
docx2txt.pl*                    msys-xml2-2.dll*
dos2unix.exe*                   msys-xslt-1.dll*
du.exe*                         msys-z.dll*
dumpsexp.exe*                   mv.exe*
echo.exe*                       nano.exe*
egrep*                          nettle-hash.exe*
env.exe*                        nettle-lfib-stream.exe*
envsubst.exe*                   nettle-pbkdf2.exe*
ex.exe*                         ngettext.exe*
expand.exe*                     nice.exe*
expr.exe*                       nl.exe*
factor.exe*                     nohup.exe*
false.exe*                      notepad*
fgrep*                          nproc.exe*
fido2-assert.exe*               numfmt.exe*
fido2-cred.exe*                 od.exe*
fido2-token.exe*                openssl.exe*
file.exe*                       p11-kit.exe*
find.exe*                       passwd.exe*
findssl.sh*                     paste.exe*
fmt.exe*                        patch.exe*
fold.exe*                       pathchk.exe*
funzip.exe*                     perl.exe*
gapplication.exe*               perl5.30.2.exe*
gawk.exe*                       pinentry.exe*
gawk-5.0.0.exe*                 pinentry-w32.exe

总结

这次安装 GPG 顺藤摸瓜,发现了 Git 自带的一些命令,对于 Windows 开发的用户实在是非常方便。这样可以节约我们安装一些软件的时间,免去不少麻烦。

如果你不想配置环境变量,在 Git Bash 中使用也是没问题的。