Skip to content

Instantly share code, notes, and snippets.

@zackslash
Last active February 13, 2025 18:11
Show Gist options
  • Save zackslash/d10e7098d5e0d4396fb2c42e6de3e414 to your computer and use it in GitHub Desktop.
Save zackslash/d10e7098d5e0d4396fb2c42e6de3e414 to your computer and use it in GitHub Desktop.
Setup GIT for signed commits without requesting passphrase on each commit

The following should allow you to perform signed git actions without having to input your passphrase everytime (These steps are for OSX)

[ -f ~/.gpg-agent-info ] && source ~/.gpg-agent-info
if [ -S "${GPG_AGENT_INFO%%:*}" ]; then
  export GPG_AGENT_INFO
else
  eval $( gpg-agent --daemon --write-env-file ~/.gpg-agent-info )
fi
export GPG_TTY=`tty`
  • Do a signed git commit and enter your GPG passphrase when prompted git commit --gpg-sign -m "q"

  • Do a git stash, if requested enter your GPG passphrase

  • Optional: set global signing key git config --global user.signingkey <Your key ID>

@TomK
Copy link

TomK commented Apr 6, 2016

to default signing all commits across all projects: git config --global commit.gpgsign true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment