Publicamos atualizações frequentes em nossa documentação, e a tradução desta página ainda pode estar em andamento. Para acessar as informações mais atualizadas, visite a Documentação em inglês.
To sign commits locally, you need to inform Git that there's a GPG or X.509 key you'd like to use.
Telling Git about your GPG key
If you're using a GPG key that matches your committer identity and your verified email address associated with your account on your GitHub Enterprise Server instance, then you can begin signing commits and signing tags.
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 "Associating an email with your GPG key".
If you have multiple GPG keys, you need to tell Git which one to use.
Abra TerminalTerminalGit Bash.
If you have previously configured Git to use a different key format when signing with --gpg-sign, unset this configuration so the default format of openpgp will be used.
$ git config --global --unset gpg.format
Use o comando gpg --list-secret-keys --keyid-format=long para listar a forma longa das chaves GPG para as quais você tem uma chave pública e privada. Uma chave privada é necessária para assinar commits ou tags.
Shell
$ gpg --list-secret-keys --keyid-format=long
Observação: algumas instalações de GPG no Linux podem exigir o uso de gpg2 --list-keys --keyid-format LONG para ver uma lista das chaves existentes. Nesse caso, você também precisará configurar o Git para usar gpg2 executando git config --global gpg.program gpg2.
Da lista de chaves GPG, copie a forma longa do ID da chave GPG que você gostaria de usar. Neste exemplo, a ID da chave GPG é 3AA5C34371567BD2:
Para definir a sua chave de assinatura GPG principal no Git, cole o texto abaixo, substituindo o ID da chave GPG principal que você gostaria de usar. Neste exemplo, a ID da chave GPG é 3AA5C34371567BD2:
If you aren't using the GPG suite, run the following command in the zsh shell to add the GPG key to your .zshrc file, if it exists, or your .zprofile file:
$ if [ -r ~/.zshrc ]; then echo 'export GPG_TTY=$(tty)' >> ~/.zshrc; \
else echo 'export GPG_TTY=$(tty)' >> ~/.zprofile; fi
Alternatively, if you use the bash shell, run this command:
$ if [ -r ~/.bash_profile ]; then echo 'export GPG_TTY=$(tty)' >> ~/.bash_profile; \
else echo 'export GPG_TTY=$(tty)' >> ~/.profile; fi
Optionally, to prompt you to enter a PIN or passphrase when required, install pinentry-mac. For example, using Homebrew:
If you're using a GPG key that matches your committer identity and your verified email address associated with your account on your GitHub Enterprise Server instance, then you can begin signing commits and signing tags.
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 "Associating an email with your GPG key".
If you have multiple GPG keys, you need to tell Git which one to use.
Abra TerminalTerminalGit Bash.
If you have previously configured Git to use a different key format when signing with --gpg-sign, unset this configuration so the default format of openpgp will be used.
$ git config --global --unset gpg.format
Use o comando gpg --list-secret-keys --keyid-format=long para listar a forma longa das chaves GPG para as quais você tem uma chave pública e privada. Uma chave privada é necessária para assinar commits ou tags.
Shell
$ gpg --list-secret-keys --keyid-format=long
Observação: algumas instalações de GPG no Linux podem exigir o uso de gpg2 --list-keys --keyid-format LONG para ver uma lista das chaves existentes. Nesse caso, você também precisará configurar o Git para usar gpg2 executando git config --global gpg.program gpg2.
Da lista de chaves GPG, copie a forma longa do ID da chave GPG que você gostaria de usar. Neste exemplo, a ID da chave GPG é 3AA5C34371567BD2:
Para definir a sua chave de assinatura GPG principal no Git, cole o texto abaixo, substituindo o ID da chave GPG principal que você gostaria de usar. Neste exemplo, a ID da chave GPG é 3AA5C34371567BD2:
If you're using a GPG key that matches your committer identity and your verified email address associated with your account on your GitHub Enterprise Server instance, then you can begin signing commits and signing tags.
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 "Associating an email with your GPG key".
If you have multiple GPG keys, you need to tell Git which one to use.
Abra TerminalTerminalGit Bash.
If you have previously configured Git to use a different key format when signing with --gpg-sign, unset this configuration so the default format of openpgp will be used.
$ git config --global --unset gpg.format
Use o comando gpg --list-secret-keys --keyid-format=long para listar a forma longa das chaves GPG para as quais você tem uma chave pública e privada. Uma chave privada é necessária para assinar commits ou tags.
Shell
$ gpg --list-secret-keys --keyid-format=long
Observação: algumas instalações de GPG no Linux podem exigir o uso de gpg2 --list-keys --keyid-format LONG para ver uma lista das chaves existentes. Nesse caso, você também precisará configurar o Git para usar gpg2 executando git config --global gpg.program gpg2.
Da lista de chaves GPG, copie a forma longa do ID da chave GPG que você gostaria de usar. Neste exemplo, a ID da chave GPG é 3AA5C34371567BD2:
Para definir a sua chave de assinatura GPG principal no Git, cole o texto abaixo, substituindo o ID da chave GPG principal que você gostaria de usar. Neste exemplo, a ID da chave GPG é 3AA5C34371567BD2:
Configure o Git para usar o S/MIME para assinar commits e tags. No Git 2.19 ou posterior, use os comandos git config gpg.x509.program e git config gpg.format:
Para usar o S/MIME para assinar todos os repositórios:
No Git 2.18 ou anterior, use o comando git config gpg.program:
Para usar o S/MIME para assinar todos os repositórios:
$ git config --global gpg.program smimesign
Para usar o S/MIME para assinar um único repositório:
$ cd /path/to/my/repository
$ git config --local gpg.program smimesign
Se você estiver usando uma chave X.509 que corresponde � sua identidade do committer, poderá começar a assinar commits e tags.
Se você não estiver usando uma chave X.509 que corresponda � identidade do autor do commit, liste as chaves X.509 para as quais você tem um certificado e uma chave privada usando o comando smimesign --list-keys.
$ smimesign --list-keys
Da lista de chaves X.509, copie o ID de certificado da chave X.509 que gostaria de usar. Neste exemplo, a ID do certificado é 0ff455a2708394633e4bb2f88002e3cd80cbd76f: