{"id":4296,"date":"2018-01-22T18:00:17","date_gmt":"2018-01-22T18:00:17","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2018\/01\/22\/how-to-sign-tags-and-commits-with-git-2\/"},"modified":"2024-01-23T13:05:22","modified_gmt":"2024-01-23T18:05:22","slug":"how-to-sign-tags-and-commits-with-git","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/website\/git\/how-to-sign-tags-and-commits-with-git\/","title":{"rendered":"How to Sign Tags and Commits with Git"},"content":{"rendered":"<p>You may remember in our previous articles, we learned how to <a href=\"\/support\/website\/git\/how-to-commit-changes-in-git-2\/\">commit changes<\/a> in our project to Git. We also learned how to <a href=\"https:\/\/www.inmotionhosting.com\/support\/website\/git\/git-tags\/\">add tags<\/a> to various commits in order to mark special milestones. Now we&#8217;re going to learn <strong>how to &#8220;sign&#8221; tags and commits with GPG.<\/strong><\/p>\n<p>Signing commits and tags is a way of verifying that a certain commit or tag has been verified by a certain user. This can be part of a contribution policy or as a protective measure to make sure that a commit is coming from a legitimate source.<\/p>\n<p>Before you can sign tags and commits, you must make sure you have a <a href=\"\/support\/email\/how-to-create-a-gpg-key\/\">GPG (or GnuPG) key<\/a> available. This key is installed on your computer, and you can use it to <a href=\"\/support\/email\/easy-email-encryption-with-thunderbird-and-enigmail\/\">sign and encrypt emails<\/a> or to encrypt and decrypt files. In the example below, we will use this key to sign our tags and commits.<\/p>\n<h2>How to Add a GPG Key to Your User Configuration<\/h2>\n<p>In order to use the GPG key on your computer, you will need to add it to the config file. You may remember in the article on <a href=\"\/support\/website\/git\/how-to-add-files-to-git-2\/\">adding files to Git<\/a>, we configured our username and email address we wanted to use for Git. We are going to follow a similar procedure here to add our key.<\/p>\n<p>First, make sure you have a key ready to use.<\/p>\n<pre class=\"code_block\"> <span style=\"color: red;\">christopher@server$<\/span> gpg --list-keys<\/pre>\n<p>Here is the output of the above command:<\/p>\n<pre class=\"cli\"> pub   1024R\/84487D41 2017-11-15 [expires: 2017-11-22] uid\r\n Chris Maiorana (CC Team) &lt;chris@example.com&gt; sub   1024R\/32B16A59 2017-11-15 [expires: 2017-11-22]<\/pre>\n<p>The key you will want to use for signing is your public key labelled &#8220;pub&#8221; above.<\/p>\n<p>In order to add your key to the Git configuration, open your terminal app and run this command with the numbers following the forward slash after &#8220;pub&#8221;:<\/p>\n<pre class=\"code_block\"> git config --global user.signingkey <span style=\"color: green;\">84487D41<\/span><\/pre>\n<h2>How to Sign Commits<\/h2>\n<p>Signing commits is easy. All we need to do is add the <code>-S<\/code> option to the <code>git commit<\/code> command.<\/p>\n<ol class=\"article_list\">\n<li>Open your project via command line or <a href=\"\/support\/server\/ssh\/what-is-shell-access\/\">SSH<\/a><\/li>\n<li>Navigate to the project directory<\/li>\n<li>Use the <code>git commit<\/code> with the following options:\n<pre class=\"code_block\"> git commit -a -S -m \"<span style=\"color: green;\">Your commit message<\/span>\"<\/pre>\n<\/li>\n<\/ol>\n<p>The <code>-a<\/code> option adds changes to the staging index automatically, the <code>-S<\/code> options signs the commit with your GPG key, and the <code>-m<\/code> option allows you to put your commit message in quotes following the command.<\/p>\n<p>The output of the above command will look similar to this:<\/p>\n<pre class=\"cli\"> christopher@server$ git commit -a -S -m \"<span style=\"color: green;\">Your commit message<\/span>\"  You need a passphrase to unlock the secret key for user: \"Chris Maiorana (CC Team) &lt;chris@example.com&gt;\" 1024-bit RSA key, ID 84487D41, created 2017-11-15  master [master ef3fab3] Your commit message  1 file changed, 748 insertions(+), 740 deletions(-)<\/pre>\n<h2>How to Sign Tags<\/h2>\n<p>It&#8217;s easy to sign tags with the addition of the <code>-s<\/code> option to the <code>git tag<\/code> command. Remember that the tag will be assigned to the most recent commit.<\/p>\n<ol class=\"article_list\">\n<li>Open your project via command line or <a href=\"\/support\/server\/ssh\/what-is-shell-access\/\">SSH<\/a><\/li>\n<li>Navigate to the project directory<\/li>\n<li>Enter the following command:\n<pre class=\"code_block\"> git tag -s <span style=\"color: green;\">your tag<\/span> -m \"<span style=\"color: green;\">your tag message<\/span>\"<\/pre>\n<\/li>\n<\/ol>\n<p>After you have signed your tag, you can view it later with the <code>git show<\/code> command:<\/p>\n<pre>christopher@server$ git show v1.4 tag v1.4 Tagger: \r\n \r\nChristopherM &lt;chris@example.com&gt; Date:   Wed Nov 15 12:35:44 2017 -0500  Version 1.4 Signed \r\n\r\n-----BEGIN PGP SIGNATURE----- \r\nVersion: GnuPG v1  iJwEAAECAAYFAloMevAACgkQ19n8W4RIfUGwBgQArTjp8UtKvmt1RBEvlNvZ7Qe0 W+jzYRUQxLh2eXBA5jIpaqHRT4RMQ7qEpwJs1w+Iwj1XcaEWZuH3dFE+Ic3KhY3h msiJdIxTOQU8MyJ9c5f5DBSSVULNFj0ibmU3P85XF0W9DMGIoyUtReBnFImPYaoo CjPowzRQ9Vi7SDRtz04= =ojrH \r\n-----END PGP SIGNATURE-----  \r\n\r\ncommit 136c043c1cb6b5baa72ead64aba468e1982e60d0 \r\nAuthor: ChristopherM &lt;chris@example.com&gt; Date:   Wed Nov 8 18:04:35 2017 -0500      \r\nVersion 4 (commit message)\r\n&lt;\/chris@example.com&gt;&lt;\/chris@example.com&gt;<\/pre>\n<p>Well done! You now know <strong>how to sign tags and commits in Git<\/strong> using GPG keys.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You may remember in our previous articles, we learned how to commit changes in our project to Git. We also learned how to add tags to various commits in order to mark special milestones. Now we&#8217;re going to learn how to &#8220;sign&#8221; tags and commits with GPG. Signing commits and tags is a way of<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/website\/git\/how-to-sign-tags-and-commits-with-git\/\"> Read More ><\/a><\/p>\n","protected":false},"author":17,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4309],"tags":[],"class_list":["post-4296","post","type-post","status-publish","format-standard","hentry","category-git"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Sign Tags and Commits with Git | InMotion Hosting<\/title>\n<meta name=\"description\" content=\"In this article, we will cover how to sign tags and commits in Git using your GPG key.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.inmotionhosting.com\/support\/website\/git\/how-to-sign-tags-and-commits-with-git\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Sign Tags and Commits with Git | InMotion Hosting\" \/>\n<meta property=\"og:description\" content=\"In this article, we will cover how to sign tags and commits in Git using your GPG key.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/website\/git\/how-to-sign-tags-and-commits-with-git\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-01-22T18:00:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-23T18:05:22+00:00\" \/>\n<meta name=\"author\" content=\"Christopher Maiorana\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Christopher Maiorana\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/git\/how-to-sign-tags-and-commits-with-git\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/git\/how-to-sign-tags-and-commits-with-git\/\"},\"author\":{\"name\":\"Christopher Maiorana\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/c6922c56c84e17079fd558e07b7ef72f\"},\"headline\":\"How to Sign Tags and Commits with Git\",\"datePublished\":\"2018-01-22T18:00:17+00:00\",\"dateModified\":\"2024-01-23T18:05:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/git\/how-to-sign-tags-and-commits-with-git\/\"},\"wordCount\":449,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"articleSection\":[\"Git\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/website\/git\/how-to-sign-tags-and-commits-with-git\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/git\/how-to-sign-tags-and-commits-with-git\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/website\/git\/how-to-sign-tags-and-commits-with-git\/\",\"name\":\"How to Sign Tags and Commits with Git | InMotion Hosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"datePublished\":\"2018-01-22T18:00:17+00:00\",\"dateModified\":\"2024-01-23T18:05:22+00:00\",\"description\":\"In this article, we will cover how to sign tags and commits in Git using your GPG key.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/git\/how-to-sign-tags-and-commits-with-git\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/website\/git\/how-to-sign-tags-and-commits-with-git\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/git\/how-to-sign-tags-and-commits-with-git\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Sign Tags and Commits with Git\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/inmotionhosting\/\",\"https:\/\/x.com\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/c6922c56c84e17079fd558e07b7ef72f\",\"name\":\"Christopher Maiorana\",\"description\":\"Christopher Maiorana joined the InMotion community team in 2015 and regularly dispenses tips and tricks in the Support Center, Community Q&A, and the InMotion Hosting Blog.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/chris-m-4623144b\/\"],\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/christopherm\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Sign Tags and Commits with Git | InMotion Hosting","description":"In this article, we will cover how to sign tags and commits in Git using your GPG key.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.inmotionhosting.com\/support\/website\/git\/how-to-sign-tags-and-commits-with-git\/","og_locale":"en_US","og_type":"article","og_title":"How to Sign Tags and Commits with Git | InMotion Hosting","og_description":"In this article, we will cover how to sign tags and commits in Git using your GPG key.","og_url":"https:\/\/www.inmotionhosting.com\/support\/website\/git\/how-to-sign-tags-and-commits-with-git\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2018-01-22T18:00:17+00:00","article_modified_time":"2024-01-23T18:05:22+00:00","author":"Christopher Maiorana","twitter_card":"summary_large_image","twitter_creator":"@InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"Christopher Maiorana","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/git\/how-to-sign-tags-and-commits-with-git\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/git\/how-to-sign-tags-and-commits-with-git\/"},"author":{"name":"Christopher Maiorana","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/c6922c56c84e17079fd558e07b7ef72f"},"headline":"How to Sign Tags and Commits with Git","datePublished":"2018-01-22T18:00:17+00:00","dateModified":"2024-01-23T18:05:22+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/git\/how-to-sign-tags-and-commits-with-git\/"},"wordCount":449,"commentCount":0,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"articleSection":["Git"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/website\/git\/how-to-sign-tags-and-commits-with-git\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/git\/how-to-sign-tags-and-commits-with-git\/","url":"https:\/\/www.inmotionhosting.com\/support\/website\/git\/how-to-sign-tags-and-commits-with-git\/","name":"How to Sign Tags and Commits with Git | InMotion Hosting","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"datePublished":"2018-01-22T18:00:17+00:00","dateModified":"2024-01-23T18:05:22+00:00","description":"In this article, we will cover how to sign tags and commits in Git using your GPG key.","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/git\/how-to-sign-tags-and-commits-with-git\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/website\/git\/how-to-sign-tags-and-commits-with-git\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/git\/how-to-sign-tags-and-commits-with-git\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"How to Sign Tags and Commits with Git"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/c6922c56c84e17079fd558e07b7ef72f","name":"Christopher Maiorana","description":"Christopher Maiorana joined the InMotion community team in 2015 and regularly dispenses tips and tricks in the Support Center, Community Q&A, and the InMotion Hosting Blog.","sameAs":["https:\/\/www.linkedin.com\/in\/chris-m-4623144b\/"],"url":"https:\/\/www.inmotionhosting.com\/support\/author\/christopherm\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":null,"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/4296","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=4296"}],"version-history":[{"count":6,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/4296\/revisions"}],"predecessor-version":[{"id":108778,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/4296\/revisions\/108778"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=4296"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=4296"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=4296"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}