Skip to content

GnuPG

2 posts with the tag “GnuPG”

Git Configuration

In this article, we introduces git configuration for basic use.

Remarkablely, configurations for symbolic links are supported on Windows with extra settings.

The purpose we have to point out, is the git compatibility on both Windows and Unix like system.

  • Config User Name
git config --global user.name 'NAME'
  • Config User Email
git config --global user.email 'EMAIL@EXAMPLE.COM'
  • Config signingkey
git config --global user.signingkey XXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXX: Personal gpg private key in LONG or SHORT format

  • Config GPG
git config --global gpg.program C:\\Program Files (x86)\\GnuPG\\bin\\gpg.exe
  • Config Commit and Tag
git config --global commit.gpgsign true
git config --global tag.gpgsign true

3. Config Git on Windows for compatibility with Unix like system

Section titled “3. Config Git on Windows for compatibility with Unix like system”
  • Config filemode authority
git config --global core.filemode false
  • Config CRLF and LF auto change
git config --global core.autocrlf true
  • Config case-sensitive
git config --global core.ignorecase false
  • Config symlinks
git config --global core.symlinks true
  • Enable Develop Mode on Windows10 and later
  • Enable symlinks on installing git on Windows
  • Group Policy:
    • Navigate to create user permission to create symbolic links:
    • Computer Configuration → Windows Settings → Security Settings → Local Policies → User Rights Assignment → Create symbolic links
    • type the user name and click “Check Names” then OK.
git config --global filter.lfs.smudge "git-lfs smudge --skip -- %f"
git config --global filter.lfs.process "git-lfs filter-process --skip"
[core]
symlinks = true
autocrlf = true
filemode = false
ignorecase = false
[user]
name = User Name
email = Username@example.com
signingkey = XXXXXXXXXXXXXXXX
[commit]
gpgsign = true
[tag]
gpgsign = true
[gpg]
program = C:\\Program Files (x86)\\GnuPG\\bin\\gpg.exe
[filter "lfs"]
smudge = git-lfs smudge --skip -- %f
process = git-lfs filter-process --skip
mklink [[/d] | [/h] | [/j]] <link> <target>

/d Creates a directory symbolic link. By default, this command creates a file symbolic link.

/h Creates a hard link instead of a symbolic link.

/j Creates a Directory Junction.

<link> Specifies the name of the symbolic link being created.

<target> Specifies the path (relative or absolute) that the new symbolic link refers to.

/? Displays help at the command prompt.

git tag XXXX
git tag -d <tagname>
git push origin --delete <tagname>
git push origin <tagname>
git branch -d <branchname>
git push origin --delete <branchname>

[1]. https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work

[2]. https://github.com/git-for-windows/git/wiki/Symbolic-Links

[3]. https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mklink

[4]. 从一个git仓库提交代码到另一个仓库

[5]. GitLab-CI-CD-Push-to-Repository

Introduction to OpenPGP

gpg --expert --full-gen-key

  • --expert: expert mode.
  • --full-gen-key: generate a key.

gpg --gen-revoke -so revoke.gpg USERID

gpg --list-secret-keys or the short form gpg -K

  • --keyid-format long: output long key IDs.
  • --fingerprint: output fingerprint information.

Import from a file:

gpg --import [file]

gpg -ao public-key.txt --export USERID

Export the primary private key:

gpg -ao secret-key --export-secret-key 99F583599B7E31F1!

Export a subkey:

gpg -ao sign-subkey --export-secret-subkeys FDB960B857D397F6!

  • ! means only that key is exported.

Delete a private key:

gpg --delete-secret-keys USERID

Delete a public key:

gpg --delete-keys USERID

Generate a binary signature file:

gpg --sign input.txt

Generate an ASCII armored signature:

gpg --clearsign input.txt

Generate a detached signature:

gpg --armor --detach-sign input.txt

  • Add --output to write the result to a file.

Verify a signature file:

gpg --verify demo.txt.asc demo.txt

gpg --recipient {keyid/uid} --output encrypt.txt --encrypt input.txt

gpg -se -o encrypt.txt -r {keyid/uid} input.txt

gpg --decrypt encrypt.txt --output decrypt.txt

gpg -d encrypt.txt

[1]. SSH-Authentication-with-GPG-Keys-on-Linux

[2]. GnuPG-Home-Configuration-on-Winodws