Initial git & github configuration

gpg keys

  • Generate gpg keys:

  • Add gpg key to github:

  • Tell to git which key to use

  • Tell git to sign all commits:

    git config --global commit.gpgsign true
  • Make gpg remember your passphrase

    # Update gpg-agent config
    # 28800 is 8 hours
    echo "default-cache-ttl 28800" >> ~/.gnupg/gpg-agent.conf
    echo "max-cache-ttl 28800" >> ~/.gnupg/gpg-agent.conf
    # tell git to use gpg-agent
    git config --global gpg.program gpg2
    # install gpg2 if needed
    sudo apt-get install gnupg2
    # You may need to set GPG_TTY:
    echo "export GPG_TTY=\"$( tty )\"" >> ~/.bashrc
    # restart gpg-agent
    gpgconf --kill gpg-agent
    gpg-agent --daemon
  • Make a backup if needed

    # make backup file and move it to secret place
    gpg --export-secret-keys > secret-backup.gpg
    # you will be able to restore keys by following command:
    gpg --import secret-backup.gpg
    # or
    gpg2 --import secret-backup.gpg


If you lost your key or forgot password, you need to create new one, but don’t remove old one from github, because otherwise all signed by old key commits will become “Unverified”

git email

  • Configure email in git. Email must be the same as in github settings:

    git config --global ""

git editor

git config --global core.editor "nano"