{"version":"https://jsonfeed.org/version/1.1","title":"Vic Demuzere - Git","home_page_url":"https://vic.demuzere.be/articles/tags/git/","feed_url":"https://vic.demuzere.be/articles/tags/git/feed.json","description":"Blog posts tagged Git by Vic Demuzere","language":"en","items":[{"id":"https://vic.demuzere.be/articles/cryptographically-signing-git-commits-tags/","content_html":"<p>Git lists the author of every commit ever made to a repository.\nThis comes in quite handy, but is easy to fake.\nAuthor data is simply read from the configuration file without any validation.\nThis means you could easily commit to an (open source) repository and pretend to be me.</p>\n<pre><code>git config --global user.name &quot;Your Name&quot;\ngit config --global user.email you@example.com\n</code></pre>\n<p>The author data is especially important when something goes wrong.\nImagine a certain commit caused a security issue, or broke software in a way that should have been caught by tests.\nWho made this change?\nIt is clear that we shouldn't trust the author listed by <code>git log</code> in this case.</p>\n<p>Tags have partially solved this issue by allowing you to PGP sign them.\nAs the git commit hash includes the parent hash, this signature validates the complete history up to that specific tag.\nThe PGP signature is made by your personal key and is harder to fake.</p>\n<h2 id=\"tags-with-a-signature\">Tags with a signature<a href=\"#tags-with-a-signature\" aria-label=\"Link to heading 'Tags with a signature'\" data-heading-content=\"Tags with a signature\" class=\"anchor\"></a></h2>\n<p>Creating a signed tag is easy once you have set up your private key in GnuPG.\nExecute the <code>tag</code> command with the <code>-s</code> flag to sign the tag as you create it.</p>\n<pre><code>git tag -s &lt;name&gt;\n</code></pre>\n<p>Git should be able to automatically find your PGP key based on the e-mail address you've listed in the <code>user.email</code> setting.\nIn case you don't want git to figure this out, it is also possible to set a default signing key globally:</p>\n<pre><code>git config --global user.signingkey 1234ABCD\n</code></pre>\n<p>That's it! Now your tag is signed. This moves the problem but doesn't actually solve it.\nSigned tags allow you to declare that you have <em>checked the commit log</em> and verified that it wasn't tampered with.\nIt is now possible to verify the tag using <code>git tag -v</code>.\nThis works fine for small projects and teams with only a few developers.\nBut what if you're managing something bigger?</p>\n<p>Your initial problem remains: How do you know for sure who changed your code?\nThe real solution is obvious...</p>\n<h2 id=\"signing-every-commit\">Signing every commit<a href=\"#signing-every-commit\" aria-label=\"Link to heading 'Signing every commit'\" data-heading-content=\"Signing every commit\" class=\"anchor\"></a></h2>\n<p>Git v1.7.9 introduced the ability to cryptographically sign commits, similar to how it works with tags.\nThe difference here is that the shortcode is uppercase <code>-S</code> as the lowercase flag is used for the <code>Signed-off-by</code> field already.\nOther than that, usage is pretty much the same.</p>\n<pre><code>git commit -am &quot;Fixed something somewhere&quot; -S 1234ABCD\n</code></pre>\n<p>There is quite a bit discussion about whether it is useful to sign every commit.\nLinus Torvalds <a href=\"https://web.archive.org/web/20210415082241/http://git.661346.n2.nabble.com/GPG-signing-for-git-commit-td2582986.html\" title=\"Linus Torvalds on commit signing.\">explained why he thinks signing commits is a bad idea</a> on a mailing list several years ago.\nThe most important part is quoted below, but you should really read the whole message to get the full picture:</p>\n<blockquote>\n<p>Signing each commit is totally stupid.\nIt just means that you automate it, and you make the signature worth less.\nIt also doesn't add any real value, since the way the git DAG-chain of SHA1's work, you only ever need one signature to make all the commits reachable from that one be effectively covered by that one.\nSo signing each commit is simply missing the point.</p>\n</blockquote>\n<p><del>Git doesn't provide a way to automatically sign every commit, although you could use a bash alias or something similar to make signing semi-automatic.</del></p>\n<p>Update: Since Git 2.0 it is possible to configure Git to sign all your commits using the <a href=\"https://git-scm.com/docs/git-config#Documentation/git-config.txt-commitgpgSign\" title=\"Git config: commit.gpgsign\">commit.gpgsign</a> option.</p>\n<div class=\"footer\"><hr><p>Thanks for subscribing to my feed!</p><p>Feel free to e-mail comments or corrections to <a href=\"mailto:vic@demuzere.be?subject=RE%3A%20How%20to%20sign%20your%20project%27s%20git%20history\">vic@demuzere.be</a>.</p></div>","url":"https://vic.demuzere.be/articles/cryptographically-signing-git-commits-tags/","date_published":"2015-03-22T11:50:50Z","date_modified":"2025-03-28T08:56:26Z","language":"en"},{"id":"https://vic.demuzere.be/articles/git-cheatsheet/","content_html":"<p>This article contains a few useful git commands.</p>\n<h2 id=\"gui-tools\">Gui tools<a href=\"#gui-tools\" aria-label=\"Link to heading 'Gui tools'\" data-heading-content=\"Gui tools\" class=\"anchor\"></a></h2>\n<p>Open the built-in graphical tool for commits (requires tk):</p>\n<pre><code>git gui\n</code></pre>\n<p>Start a local webserver to browse the repository, open in chromium:\n(Requires lighttpd)</p>\n<pre><code>git instaweb -b chromium\n</code></pre>\n<h2 id=\"local-repository\">Local repository<a href=\"#local-repository\" aria-label=\"Link to heading 'Local repository'\" data-heading-content=\"Local repository\" class=\"anchor\"></a></h2>\n<p>Create a new repository in the current directory:</p>\n<pre><code>git init\n</code></pre>\n<p>Add a new file to the repository:</p>\n<pre><code>git add &lt;file&gt;\n</code></pre>\n<p>Commit all pending changes:</p>\n<pre><code>git commit -am &lt;message&gt;\n</code></pre>\n<h2 id=\"remotes\">Remotes<a href=\"#remotes\" aria-label=\"Link to heading 'Remotes'\" data-heading-content=\"Remotes\" class=\"anchor\"></a></h2>\n<p>View all remotes linked to from this repository:</p>\n<pre><code>git remote\n</code></pre>\n<p>Add a new remote</p>\n<pre><code>git remote add &lt;name&gt; &lt;url&gt;\n</code></pre>\n<p>Remove a remote</p>\n<pre><code>git remote rm &lt;name&gt;\n</code></pre>\n<p>Push local changes to a remote</p>\n<pre><code>git push &lt;remote&gt;\n</code></pre>\n<p>Push local tags to a remote</p>\n<pre><code>git push --tags &lt;remote&gt;\n</code></pre>\n<p>Pull changes from a remote</p>\n<pre><code>git pull &lt;remote&gt;\n</code></pre>\n<h2 id=\"tags\">Tags<a href=\"#tags\" aria-label=\"Link to heading 'Tags'\" data-heading-content=\"Tags\" class=\"anchor\"></a></h2>\n<p>Create a signed tag (Requires a PGP key)</p>\n<pre><code>git tag -s &lt;name&gt;\n</code></pre>\n<p>Verify a signed tag</p>\n<pre><code>git tag -v &lt;name&gt;\n</code></pre>\n<h2 id=\"branches\">Branches<a href=\"#branches\" aria-label=\"Link to heading 'Branches'\" data-heading-content=\"Branches\" class=\"anchor\"></a></h2>\n<p>Remove a remote branch</p>\n<pre><code>git push &lt;remote&gt; :&lt;branch&gt;\n</code></pre>\n<div class=\"footer\"><hr><p>Thanks for subscribing to my feed!</p><p>Feel free to e-mail comments or corrections to <a href=\"mailto:vic@demuzere.be?subject=RE%3A%20Git%20Cheat-Sheet\">vic@demuzere.be</a>.</p></div>","url":"https://vic.demuzere.be/articles/git-cheatsheet/","date_published":"2012-02-09T18:00:00Z","date_modified":"2023-11-28T19:55:32Z","language":"en"}]}