Versão do artigo: Enterprise Server 2.17
Informar ao Git sobre a chave de assinatura
Para assinar commits localmente, é preciso informar ao Git que há uma chave GPG ou X.509 que você deseja usar.
Informar ao Git sobre a chave GPG
Se você estiver usando uma chave GPG que corresponda à identidade do committer (autor do commit) e ao endereço de e-mail associado à conta do GitHub Enterprise, você poderá começar a assinar commits e tags.
Se você não tiver uma chave GPG que corresponda à identidade do committer, precisará associar um e-mail a uma chave existente. Para obter mais informações, consulte "Associar e-mail à chave GPG".
Se você tiver várias chaves GPG, precisará informar ao Git qual deve ser usada.
- 
Open TerminalTerminalGit Bash. 
- 
Use the gpg --list-secret-keys --keyid-format LONGcommand to list GPG keys for which you have both a public and private key. A private key is required for signing commits or tags.$ gpg --list-secret-keys --keyid-format LONGNote: Some GPG installations on Linux may require you to use gpg2 --list-keys --keyid-format LONGto view a list of your existing keys instead. In this case you will also need to configure Git to usegpg2by runninggit config --global gpg.program gpg2.
- 
From the list of GPG keys, copy the GPG key ID you'd like to use. Neste exemplo, o ID da chave GPG é 3AA5C34371567BD2:$ gpg --list-secret-keys --keyid-format LONG /Users/hubot/.gnupg/secring.gpg ------------------------------------ sec 4096R/3AA5C34371567BD2 2016-03-10 [expires: 2017-03-10] uid Hubotssb 4096R/42B317FD4BA89E7A 2016-03-10 
- 
To set your GPG signing key in Git, paste the text below, substituting in the GPG key ID you'd like to use. Neste exemplo, o ID da chave GPG é 3AA5C34371567BD2:$ git config --global user.signingkey 3AA5C34371567BD2
- 
Se você não estiver usando o conjunto de GPG, cole o texto abaixo para adicionar a chave GPG ao seu perfil de bash: $ test -r ~/.bash_profile && echo 'export GPG_TTY=$(tty)' >> ~/.bash_profile $ echo 'export GPG_TTY=$(tty)' >> ~/.profileObservação: se você não tiver .bash_profile, este comando adicionará sua chave GPG a.profile.
Telling Git about your X.509 key
You can use smimesign to sign commits and tags using S/MIME instead of GPG.
Note: S/MIME signature verification is available in Git 2.19 or later. To update your version of Git, see the Git website.
- Install smimesign.
- Open TerminalTerminalGit Bash.
- Configure Git to use S/MIME to sign commits and tags. In Git 2.19 or later, use the git config gpg.x509.programandgit config gpg.formatcommands:
- To use S/MIME to sign for all repositories:$ git config --global gpg.x509.program smimesign $ git config --global gpg.format x509
- To use S/MIME to sign for a single repository:
 In Git 2.18 or earlier, use the$ cd /path/to/my/repository $ git config --local gpg.x509.program smimesign $ git config --local gpg.format x509git config gpg.programcommand:
- To use S/MIME to sign for all repositories:$ git config --global gpg.program smimesign
- To use S/MIME to sign for a single repository:
 If you're using an X.509 key that matches your committer identity, you can begin signing commits and tags.$ cd /path/to/my/repository $ git config --local gpg.program smimesign
- If you're not using an X.509 key that matches your commiter identity, list X.509 keys for which you have both a certificate and private key using the smimesign --list-keyscommand.$ smimesign --list-keys
- From the list of X.509 keys, copy the certificate ID of the X.509 key you'd like to use. In this example, the certificate ID is 0ff455a2708394633e4bb2f88002e3cd80cbd76f:$ smimesign --list-keys ID: 0ff455a2708394633e4bb2f88002e3cd80cbd76f S/N: a2dfa7e8c9c4d1616f1009c988bb70f Algorithm: SHA256-RSA Validity: 2017-11-22 00:00:00 +0000 UTC - 2020-11-22 12:00:00 +0000 UTC Issuer: CN=DigiCert SHA2 Assured ID CA,OU=www.digicert.com,O=DigiCert Inc,C=US Subject: CN=Octocat,O=GitHub\, Inc.,L=San Francisco,ST=California,C=US Emails: octocat@github.com
- To set your X.509 signing key in Git, paste the text below, substituting in the certificate ID you copied earlier.
- To use your X.509 key to sign for all repositories:$ git config --global user.signingkey 0ff455a2708394633e4bb2f88002e3cd80cbd76f
- To use your X.509 key to sign for a single repository:$ cd /path/to/my/repository $ git config --local user.signingkey 0ff455a2708394633e4bb2f88002e3cd80cbd76f
Informar ao Git sobre a chave GPG
Se você estiver usando uma chave GPG que corresponda à identidade do committer (autor do commit) e ao endereço de e-mail associado à conta do GitHub Enterprise, você poderá começar a assinar commits e tags.
Se você não tiver uma chave GPG que corresponda à identidade do committer, precisará associar um e-mail a uma chave existente. Para obter mais informações, consulte "Associar e-mail à chave GPG".
Se você tiver várias chaves GPG, precisará informar ao Git qual deve ser usada.
- 
Open TerminalTerminalGit Bash. 
- 
Use the gpg --list-secret-keys --keyid-format LONGcommand to list GPG keys for which you have both a public and private key. A private key is required for signing commits or tags.$ gpg --list-secret-keys --keyid-format LONGNote: Some GPG installations on Linux may require you to use gpg2 --list-keys --keyid-format LONGto view a list of your existing keys instead. In this case you will also need to configure Git to usegpg2by runninggit config --global gpg.program gpg2.
- 
From the list of GPG keys, copy the GPG key ID you'd like to use. Neste exemplo, o ID da chave GPG é 3AA5C34371567BD2:$ gpg --list-secret-keys --keyid-format LONG /Users/hubot/.gnupg/secring.gpg ------------------------------------ sec 4096R/3AA5C34371567BD2 2016-03-10 [expires: 2017-03-10] uid Hubotssb 4096R/42B317FD4BA89E7A 2016-03-10 
- 
To set your GPG signing key in Git, paste the text below, substituting in the GPG key ID you'd like to use. Neste exemplo, o ID da chave GPG é 3AA5C34371567BD2:$ git config --global user.signingkey 3AA5C34371567BD2
Telling Git about your X.509 key
You can use smimesign to sign commits and tags using S/MIME instead of GPG.
Note: S/MIME signature verification is available in Git 2.19 or later. To update your version of Git, see the Git website.
- Install smimesign.
- Open TerminalTerminalGit Bash.
- Configure Git to use S/MIME to sign commits and tags. In Git 2.19 or later, use the git config gpg.x509.programandgit config gpg.formatcommands:
- To use S/MIME to sign for all repositories:$ git config --global gpg.x509.program smimesign $ git config --global gpg.format x509
- To use S/MIME to sign for a single repository:
 In Git 2.18 or earlier, use the$ cd /path/to/my/repository $ git config --local gpg.x509.program smimesign $ git config --local gpg.format x509git config gpg.programcommand:
- To use S/MIME to sign for all repositories:$ git config --global gpg.program smimesign
- To use S/MIME to sign for a single repository:
 If you're using an X.509 key that matches your committer identity, you can begin signing commits and tags.$ cd /path/to/my/repository $ git config --local gpg.program smimesign
- If you're not using an X.509 key that matches your commiter identity, list X.509 keys for which you have both a certificate and private key using the smimesign --list-keyscommand.$ smimesign --list-keys
- From the list of X.509 keys, copy the certificate ID of the X.509 key you'd like to use. In this example, the certificate ID is 0ff455a2708394633e4bb2f88002e3cd80cbd76f:$ smimesign --list-keys ID: 0ff455a2708394633e4bb2f88002e3cd80cbd76f S/N: a2dfa7e8c9c4d1616f1009c988bb70f Algorithm: SHA256-RSA Validity: 2017-11-22 00:00:00 +0000 UTC - 2020-11-22 12:00:00 +0000 UTC Issuer: CN=DigiCert SHA2 Assured ID CA,OU=www.digicert.com,O=DigiCert Inc,C=US Subject: CN=Octocat,O=GitHub\, Inc.,L=San Francisco,ST=California,C=US Emails: octocat@github.com
- To set your X.509 signing key in Git, paste the text below, substituting in the certificate ID you copied earlier.
- To use your X.509 key to sign for all repositories:$ git config --global user.signingkey 0ff455a2708394633e4bb2f88002e3cd80cbd76f
- To use your X.509 key to sign for a single repository:$ cd /path/to/my/repository $ git config --local user.signingkey 0ff455a2708394633e4bb2f88002e3cd80cbd76f
Observação: as chaves X.509 não são compatíveis com Linux. Embora seja possível configurar gpgsm para fornecer serviços de assinatura e criptografia, não há suporte para isso no GitHub Enterprise. Para obter mais informações, consulte o tópico gpgsm na documentação do GnuPG.
Informar ao Git sobre a chave GPG
Se você estiver usando uma chave GPG que corresponda à identidade do committer (autor do commit) e ao endereço de e-mail associado à conta do GitHub Enterprise, você poderá começar a assinar commits e tags.
Se você não tiver uma chave GPG que corresponda à identidade do committer, precisará associar um e-mail a uma chave existente. Para obter mais informações, consulte "Associar e-mail à chave GPG".
Se você tiver várias chaves GPG, precisará informar ao Git qual deve ser usada.
- 
Open TerminalTerminalGit Bash. 
- 
Use the gpg --list-secret-keys --keyid-format LONGcommand to list GPG keys for which you have both a public and private key. A private key is required for signing commits or tags.$ gpg --list-secret-keys --keyid-format LONGNote: Some GPG installations on Linux may require you to use gpg2 --list-keys --keyid-format LONGto view a list of your existing keys instead. In this case you will also need to configure Git to usegpg2by runninggit config --global gpg.program gpg2.
- 
From the list of GPG keys, copy the GPG key ID you'd like to use. Neste exemplo, o ID da chave GPG é 3AA5C34371567BD2:$ gpg --list-secret-keys --keyid-format LONG /Users/hubot/.gnupg/secring.gpg ------------------------------------ sec 4096R/3AA5C34371567BD2 2016-03-10 [expires: 2017-03-10] uid Hubotssb 4096R/42B317FD4BA89E7A 2016-03-10 
- 
To set your GPG signing key in Git, paste the text below, substituting in the GPG key ID you'd like to use. Neste exemplo, o ID da chave GPG é 3AA5C34371567BD2:$ git config --global user.signingkey 3AA5C34371567BD2
- 
Para adicionar a chave GPG ao seu perfil de bash, cole o texto abaixo: $ test -r ~/.bash_profile && echo 'export GPG_TTY=$(tty)' >> ~/.bash_profile $ echo 'export GPG_TTY=$(tty)' >> ~/.profileObservação: se você não tiver .bash_profile, este comando adicionará sua chave GPG a.profile.