$ gpg --full-generate-key gpg (GnuPG) 2.2.9-unknown; Copyright (C) 2018 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.
Please select what kind of key you want: (1) RSA and RSA (default) (2) DSA and Elgamal (3) DSA (sign only) (4) RSA (sign only) Your selection? 1 RSA keys may be between 1024 and 4096 bits long. What keysize do you want? (2048) 2048 Requested keysize is 2048 bits Please specify how long the key should be valid. 0 = key does not expire <n> = key expires in n days <n>w = key expires in n weeks <n>m = key expires in n months <n>y = key expires in n years Key is valid for? (0) 3m Key expires at 2019年08月 5日 10:23:27 Is this correct? (y/N) y
GnuPG needs to construct a user ID to identify your key.
Real name: guanyue Email address: guanyue003@gmail.com Comment: generate gpg-key test You selected this USER-ID: "guanyue (generate gpg-key test) <guanyue003@gmail.com>"
Change (N)ame, (C)omment, (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 F1C6C99D6C9E65C0 marked as ultimately trusted gpg: revocation certificate stored as '/c/Users/XXXXXXX/.gnupg/openpgp-revocs.d/E031D280CA50F902CB68A8BBF1C6C99D6C9E65C0.rev' public and secret key created and signed.
$ gpg --verify src.txt.asc gpg: assuming signed data in'src.txt' gpg: Signature made 2019年05月 7日 11:10:05 gpg: using RSA key E031D280CA50F902CB68A8BBF1C6C99D6C9E65C0 gpg: Good signature from "guanyue (generate gpg-key test) <guanyue003@gmail.com>" [ultimate]
接下来的两个小节将演示如何取消暂存区域中的文件,以及如何取消工作目录中已修改的文件。不用担心,查看文件状态的时候就提示了该如何撤消,所以不需要死记硬背。来看下面的例子,有两个修改过的文件,我们想要分开提交,但不小心用 git add . 全加到了暂存区域。该如何撤消暂存其中的一个文件呢?其实,git status 的命令输出已经告诉了我们该怎么做:
1 2 3 4 5 6 7 8
$ git add . $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage)
modified: README.txt modified: benchmarks.rb
就在 “Changes to be committed” 下面,括号中有提示,可以使用 git reset HEAD … 的方式取消暂存。好吧,我们来试试取消暂存 benchmarks.rb 文件:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
$ git reset HEAD benchmarks.rb Unstaged changes after reset: M benchmarks.rb $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage)
modified: README.txt
Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory)
如果觉得刚才对 benchmarks.rb 的修改完全没有必要,该如何取消修改,回到之前的状态(也就是修改之前的版本)呢?git status 同样提示了具体的撤消方法,接着上面的例子,现在未暂存区域看起来像这样:
1 2 3 4 5
Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory)