Skip to content

Instantly share code, notes, and snippets.

@sadn1ck
Last active October 28, 2020 12:28
Show Gist options
  • Save sadn1ck/68f089670ee46ecdb4b02abd820acba3 to your computer and use it in GitHub Desktop.
Save sadn1ck/68f089670ee46ecdb4b02abd820acba3 to your computer and use it in GitHub Desktop.
Setting up git

Setup git for the first time

  • git config --global user.name "your name"
  • git config --global user.email "yourEmail@email.com"
  • git config --global color.ui true

Setting up passwordless commits:

  • ssh-keygen -t rsa -C "yourEmail@email.com"
  • name it something like githubssh (generic, I know)
  • cat ~/.ssh/githubssh.pub
  • Copy that output and go to SSH and GPG keys
  • New SSH key, then paste the output of the previous command. Give it a name, add it.
  • ssh -i ~/.ssh/githubssh -T git@github.com
  • Output should say "Hi github_username! You've successfully authenticated, but GitHub does not provide shell access."
  • If not, remove the id_rsa.pub file and redo the steps. Take care if you have other ssh keys, do not delete them all.

Setting up GPG keys for verified commits:

  • gpg --full-generate-key
  • Select RSA and RSA (default), and key length as 4096.
  • Enter the asked details, and a password when prompted. When finished,
  • gpg --list-secret-keys --keyid-format LONG
  • Output should be something like:
$ gpg --list-secret-keys --keyid-format LONG

#### /Users/hubot/.gnupg/secring.gpg
------------------------------------
sec   4096R/3AA5C34371567BD2 2016-03-10 [expires: 2017-03-10]
uid                          Hubot 
ssb   4096R/42B317FD4BA89E7A 2016-03-10
  • gpg --armor --export <string after upper 4096R, here 3AA5C34371567BD2>
  • Copy that entire output and go to SSH and GPG keys
  • New GPG key, paste the previous output in the box, then press Add GPG key
  • git config --global user.signingkey <string after upper 4096R, here 3AA5C34371567BD2>
  • To push verified commits from now on, make sure you put in the -S modifier, ie, git commit -S -m "Commit Message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment