Git(Hub) Guide
Issue Management
Use any of these keywords to close an issue via commit message
close, closes, closed, fix, fixes, fixed, resolve, resolves, resolved # e.g: git commit -m "closes #1, fixes #123
Useful Git Recipes
Housekeeping
-D to include unmerged ones)git branch --merged| grep -v master | xargs git branch -d
git branch -d arm64 warning: not deleting branch 'arm64' that is not yet merged to 'refs/remotes/origin/arm64' git branch -r # list remotes git push --delete origin arm64 git branch -d arm64 # or without deleting the remote: git branch -D arm64'
git remote prune origin
git gc
Git Aliases
Works for subcommands and external commands (with leading !), see Git Aliases
git config --global alias.last 'log -1 HEAD git config --global alias.puma '! git checkout master && git pull' git config --list | grep alias # show
Signed Commits
-
Install GnuPG (free implementation of the OpenPGP standard a), generate keypair, find Key id (in the following example it would be 123456ABCDEF)
$ brew install gnupg $ gpg --full-generate-key $ gpg --list-secret-keys --keyid-format=long ~/.gnupg/pubring.kbx ---------------------------------- sec ed25519/123456ABCDEF 2021-12-13 [SC] 83122XXXXXXXX uid [ ultimativ ] This Is Me (GitHub GPG Key) <thisisme@me.com> -
Export the key, Open GitHub → Settings → Keys, import it there:
$ gpg --armor --export -----BEGIN PGP PUBLIC KEY BLOCK----- mDM (...) -----END PGP PUBLIC KEY BLOCK-----
-
Add
export GPG_TTY=$(tty)to.bashrcor equivalent (or you get "Inappropriate ioctl for device" errors), try with a simple message if it is working. See this link for more troubleshooting tips.$ echo SuperSecret |gpg --clearsign -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA(...)
-
Tell git your signing key, configure
commit.gpgsigneither pro project or globally, or use-Sswitch when committing. Verify withlog --show-signatureif the message was properly signed. You also may also have to align you commit email (settinguser.email) with the email address from your GPG key (you can add multiple IDs with different addresses to your key), and your GitHub Email Settings resp SSH and GPG Keys.$ git config --global user.signingkey 123456ABCDEF $ git config commit.gpgsign true ## only $ git commit -S -m "my verified change" $ git log --show-signature commit 3fd45023ab1bb39eaf89c504de3be353ceXXXXXX (HEAD -> gpg, origin/gpg) gpg: Signature made Mon Dec 13 10:49:38 2021 CET gpg: using EDDSA key XXXXXX