Baba Tech Blog

TR EN

Creating GPG Signed Tags with Git and Troubleshooting

Creating GPG Signed Tags with Git and Troubleshooting 🔐#

In the development process, Git tags are an important feature used to mark specific versions. However, signing these tags with GPG increases the reliability of your version and prevents unauthorized changes. In this article, we'll explain the process of creating GPG signed tags with Git and how to fix possible errors you may encounter. 🚀

1️⃣ Create Your GPG Key#

If you don't have a GPG key yet, you can create a new key with the following command:

gpg --full-generate-key

After the key is created, you can use the following command to learn your ID:

gpg --list-secret-keys --keyid-format LONG

This command will show the details of your key. Note the long key ID found under the sec tag in the output. For example:

sec   rsa4096/8416A43957C19627 2022-04-25 [SC] [expires: 2025-08-23]

Here 8416A43957C19627 part is your key ID.

2️⃣ Configure Git with GPG#

To make Git use your GPG key, run the following command:

git config --global user.signingkey 8416A43957C19627

Also, if you want to sign Git commits by default, you can run the following command:

git config --global commit.gpgsign true

3️⃣ Create Signed Git Tag ✍️#

After introducing your GPG key to Git, you can create a signed tag with the following command:

git tag -s 0.0.3 -m "Version 0.0.3' by Jekyll"

To see existing tags:

git tag

To verify a tag:

git tag -v 0.0.3

4️⃣ Push Tag to Remote Repository ☁️#

To send your signed tag to GitHub or another remote repository, you can use the following command:

git push origin 0.0.3

If you want to send all tags at once:

git push --tags

5️⃣ Windows Terminal and Git Bash GPG Issues 🔍#

If you're using Windows Terminal or Git Bash and your GPG key works in one but doesn't appear in the other, this may be related to environment variables.

🔧 Solution:#

  1. Check your home directory in Git Bash:
  echo $HOME
  1. Check your user profile in Windows Terminal:
  echo %USERPROFILE%

Make sure both directories are the same!

  1. Set the following environment variable in Windows Terminal:
  set GNUPGHOME=C:\Users\yucel\.gnupg
  1. Import your GPG key:
  gpg --import C:\Users\yucel\.gnupg\my-private-key.asc
  1. Introduce your key to Git again:
  git config --global user.signingkey 8416A43957C19627
  1. Now check again:
  gpg --list-secret-keys --keyid-format LONG

If the output is empty, check if GPG is installed system-wide.

🎯 Conclusion#

By following these steps, you can create Git tags signed with GPG, share your tags safely, and solve GPG problems between Windows Terminal & Git Bash. 🔥

GPG signatures are of great importance in open source projects, security-required corporate projects, and sensitive development processes. Get used to using them! ✅


📌 Extra Information: If you lose your GPG key, you need to create a new key and start using this new key in projects. Don't forget to revoke your old key! 🚨

git-gpg-imzali-etiket

Webmentions

Likes

  • Loading likes...

Comments & Replies

  • Loading comments...

Comments
Reply via Bluesky

With an account on the Fediverse or Mastodon, you can respond to this post.

Copy and paste this URL into the search field of your favourite Fediverse app or the web interface of your Mastodon server.

Loading comments...