5.1 KiB
title, intro, redirect_from, versions, topics, shortTitle
| title | intro | redirect_from | versions | topics | shortTitle | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Telling Git about your signing key | To sign commits locally, you need to inform Git that there's a GPG, SSH, or X.509 key you'd like to use. |
|
|
|
Tell Git about your signing key |
Telling Git about your GPG key
{% mac %}
If you're using a GPG key that matches your committer identity and your verified email address associated with your account on {% data variables.location.product_location %}, then you can begin signing commits and signing tags.
Note
If you don't have a GPG key that matches your committer identity, you need to associate an email with an existing key. For more information, see "AUTOTITLE".
If you have multiple GPG keys, you need to tell Git which one to use.
{% data reusables.command_line.open_the_multi_os_terminal %} {% data reusables.gpg.configure-gpg-signing %} {% data reusables.gpg.list-keys-with-note %} {% data reusables.gpg.copy-gpg-key-id %} {% data reusables.gpg.paste-gpg-key-id %} {% data reusables.gpg.set-auto-sign %}
-
If you aren't using the GPG suite, run the following command in the
zshshell to add the GPG key to your.zshrcfile, if it exists, or your.zprofilefile:$ if [ -r ~/.zshrc ]; then echo -e '\nexport GPG_TTY=$(tty)' >> ~/.zshrc; \ else echo -e '\nexport GPG_TTY=$(tty)' >> ~/.zprofile; fiAlternatively, if you use the
bashshell, run this command:$ if [ -r ~/.bash_profile ]; then echo -e '\nexport GPG_TTY=$(tty)' >> ~/.bash_profile; \ else echo -e '\nexport GPG_TTY=$(tty)' >> ~/.profile; fi -
Optionally, to prompt you to enter a PIN or passphrase when required, install
pinentry-mac. For example, using Homebrew:brew install pinentry-mac echo "pinentry-program $(which pinentry-mac)" >> ~/.gnupg/gpg-agent.conf killall gpg-agent
{% endmac %}
{% windows %}
If you're using a GPG key that matches your committer identity and your verified email address associated with your account on {% data variables.location.product_location %}, then you can begin signing commits and signing tags.
Note
If you don't have a GPG key that matches your committer identity, you need to associate an email with an existing key. For more information, see "AUTOTITLE".
If you have multiple GPG keys, you need to tell Git which one to use.
{% data reusables.command_line.open_the_multi_os_terminal %} {% data reusables.gpg.configure-gpg-signing %} {% data reusables.gpg.list-keys-with-note %} {% data reusables.gpg.copy-gpg-key-id %} {% data reusables.gpg.paste-gpg-key-id %} {% data reusables.gpg.set-auto-sign %}
{% endwindows %}
{% linux %}
If you're using a GPG key that matches your committer identity and your verified email address associated with your account on {% data variables.location.product_location %}, then you can begin signing commits and signing tags.
Note
If you don't have a GPG key that matches your committer identity, you need to associate an email with an existing key. For more information, see "AUTOTITLE".
If you have multiple GPG keys, you need to tell Git which one to use.
{% data reusables.command_line.open_the_multi_os_terminal %} {% data reusables.gpg.configure-gpg-signing %} {% data reusables.gpg.list-keys-with-note %} {% data reusables.gpg.copy-gpg-key-id %} {% data reusables.gpg.paste-gpg-key-id %} {% data reusables.gpg.set-auto-sign %}
-
To add your GPG key to your
.bashrcstartup file, run the following command:[ -f ~/.bashrc ] && echo -e '\nexport GPG_TTY=$(tty)' >> ~/.bashrc
{% endlinux %}
Telling Git about your SSH key
You can use an existing SSH key to sign commits and tags, or generate a new one specifically for signing. For more information, see "AUTOTITLE."
{% data reusables.gpg.ssh-git-version %}
{% data reusables.command_line.open_the_multi_os_terminal %} {% data reusables.gpg.configure-ssh-signing %} {% data reusables.gpg.paste-ssh-public-key %}
{% windows %}
{% data reusables.gpg.x-509-key %}
{% endwindows %}
{% mac %}
{% data reusables.gpg.x-509-key %}
{% endmac %}