<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Productivity on Grant Lucas</title>
    <link>https://grantlucas.com/tags/productivity/</link>
    <description>Recent content in Productivity on Grant Lucas</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Sun, 03 Mar 2024 15:19:19 -0500</lastBuildDate>
    <atom:link href="https://grantlucas.com/tags/productivity/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Override Git&#39;s User Email by Folder</title>
      <link>https://grantlucas.com/posts/2024/03/override-gits-user-email-by-folder/</link>
      <pubDate>Sun, 03 Mar 2024 15:19:19 -0500</pubDate>
      <guid>https://grantlucas.com/posts/2024/03/override-gits-user-email-by-folder/</guid>
      <description>&lt;p&gt;&lt;em&gt;Never forget to set your work email after cloning a work Git repository again!&lt;/em&gt;&lt;/p&gt;&lt;p&gt;When using a single computer for multiple categories of development (personal,&#xA;work, etc), there is often a need to set a specific &lt;code&gt;user.email&lt;/code&gt; value for each&#xA;repository cloned depending on the use. For example, it&amp;rsquo;d make sense to use your&#xA;work email for repositories cloned for work while you&amp;rsquo;d use your personal email&#xA;for you own projects.&lt;/p&gt;&#xA;&lt;p&gt;Without the following setup, it&amp;rsquo;s &lt;strong&gt;very easy&lt;/strong&gt; to forget to override your&#xA;&lt;code&gt;user.email&lt;/code&gt; at a repository level and end up committing to one or the other&#xA;with the wrong email attached. Though not the end of the world, I can imagine&#xA;your company, coworkers, and security department would prefer to see your work&#xA;email attached to all commits instead of a random Gmail account.&lt;/p&gt;&#xA;&lt;p&gt;With the following in place, &lt;strong&gt;you&amp;rsquo;ll never forget to have the correct&#xA;&lt;code&gt;user.email&lt;/code&gt; set again!&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;div class=&#34;splitbox&#34;&gt;&lt;div class=&#34;left&#34;&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The following only works if you &lt;strong&gt;split up your repository clones&#xA;within dedicated folders&lt;/strong&gt;&amp;hellip;which is probably better than mixing professional&#xA;and personal repository together anyways.&#xA;&lt;/div&gt;&lt;div class=&#34;right&#34;&gt;&#xA;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;├── personal&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;│   ├── repo1&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;│   └── repo2&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;└── work&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    ├── repo1&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    └── repo2&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&#34;clear:both&#34;&gt;&lt;/div&gt;&lt;/div&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;In your main &lt;code&gt;~/.gitconfig&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;div style=&#34;color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&#xA;&lt;table style=&#34;border-spacing:0;padding:0;margin:0;border:0;&#34;&gt;&lt;tr&gt;&lt;td style=&#34;vertical-align:top;padding:0;margin:0;border:0;&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34; id=&#34;hl-1-1&#34;&gt;&lt;a style=&#34;outline:none;text-decoration:none;color:inherit&#34; href=&#34;#hl-1-1&#34;&gt; 1&lt;/a&gt;&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34; id=&#34;hl-1-2&#34;&gt;&lt;a style=&#34;outline:none;text-decoration:none;color:inherit&#34; href=&#34;#hl-1-2&#34;&gt; 2&lt;/a&gt;&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34; id=&#34;hl-1-3&#34;&gt;&lt;a style=&#34;outline:none;text-decoration:none;color:inherit&#34; href=&#34;#hl-1-3&#34;&gt; 3&lt;/a&gt;&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34; id=&#34;hl-1-4&#34;&gt;&lt;a style=&#34;outline:none;text-decoration:none;color:inherit&#34; href=&#34;#hl-1-4&#34;&gt; 4&lt;/a&gt;&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34; id=&#34;hl-1-5&#34;&gt;&lt;a style=&#34;outline:none;text-decoration:none;color:inherit&#34; href=&#34;#hl-1-5&#34;&gt; 5&lt;/a&gt;&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34; id=&#34;hl-1-6&#34;&gt;&lt;a style=&#34;outline:none;text-decoration:none;color:inherit&#34; href=&#34;#hl-1-6&#34;&gt; 6&lt;/a&gt;&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34; id=&#34;hl-1-7&#34;&gt;&lt;a style=&#34;outline:none;text-decoration:none;color:inherit&#34; href=&#34;#hl-1-7&#34;&gt; 7&lt;/a&gt;&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34; id=&#34;hl-1-8&#34;&gt;&lt;a style=&#34;outline:none;text-decoration:none;color:inherit&#34; href=&#34;#hl-1-8&#34;&gt; 8&lt;/a&gt;&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34; id=&#34;hl-1-9&#34;&gt;&lt;a style=&#34;outline:none;text-decoration:none;color:inherit&#34; href=&#34;#hl-1-9&#34;&gt; 9&lt;/a&gt;&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34; id=&#34;hl-1-10&#34;&gt;&lt;a style=&#34;outline:none;text-decoration:none;color:inherit&#34; href=&#34;#hl-1-10&#34;&gt;10&lt;/a&gt;&#xA;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#xA;&lt;td style=&#34;vertical-align:top;padding:0;margin:0;border:0;;width:100%&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;; Set your desired default name and email&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;[user]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    name = Bob Loblaw&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    email = bob@home.com&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;; Override your user info, and anything else, depending on the folder you&amp;#39;re&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;; currently in&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;; It&amp;#39;s important this comes after anything you&amp;#39;re overriding&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;[includeIf &amp;#34;gitdir:~/Development/work/**&amp;#34;]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    path = ~/.gitconfig_work.inc&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;/div&gt;&lt;p&gt;Now in &lt;code&gt;~/.gitconfig_work.inc&lt;/code&gt; you can set your work specific information&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;div style=&#34;color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&#xA;&lt;table style=&#34;border-spacing:0;padding:0;margin:0;border:0;&#34;&gt;&lt;tr&gt;&lt;td style=&#34;vertical-align:top;padding:0;margin:0;border:0;&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34; id=&#34;hl-2-1&#34;&gt;&lt;a style=&#34;outline:none;text-decoration:none;color:inherit&#34; href=&#34;#hl-2-1&#34;&gt;1&lt;/a&gt;&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34; id=&#34;hl-2-2&#34;&gt;&lt;a style=&#34;outline:none;text-decoration:none;color:inherit&#34; href=&#34;#hl-2-2&#34;&gt;2&lt;/a&gt;&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34; id=&#34;hl-2-3&#34;&gt;&lt;a style=&#34;outline:none;text-decoration:none;color:inherit&#34; href=&#34;#hl-2-3&#34;&gt;3&lt;/a&gt;&#xA;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#xA;&lt;td style=&#34;vertical-align:top;padding:0;margin:0;border:0;;width:100%&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;[user]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    name = Bob Loblaw&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    email = bob@work.com&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;/div&gt;&lt;p&gt;With those configs, now &lt;em&gt;any&lt;/em&gt; Git interaction within &lt;code&gt;~/Development/work/**&lt;/code&gt;&#xA;will be done with &lt;code&gt;user.email&lt;/code&gt; set to &lt;code&gt;bob@work.com&lt;/code&gt;. No need for any local Git&#xA;config overrides ever again to set common settings for work vs personal&#xA;repositories.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>A Git Alias for Keeping a Tidy Development Environment</title>
      <link>https://grantlucas.com/posts/2024/02/a-git-alias-for-keeping-a-tidy-development-environment/</link>
      <pubDate>Sun, 25 Feb 2024 22:07:36 -0500</pubDate>
      <guid>https://grantlucas.com/posts/2024/02/a-git-alias-for-keeping-a-tidy-development-environment/</guid>
      <description>&lt;p&gt;Over time, whether working alone or in a team, your Git environment can become&#xA;cluttered and messy with branches of the past, both local and remote. Though&#xA;this isn&amp;rsquo;t an issue in the short term, if left alone, it can lead to time&#xA;wasting mistakes, out of date code that doesn&amp;rsquo;t work once pushed to origin, and&#xA;clutter in any Git tools or GUIs you may use leading to lower productivity.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;How many local and remote branches do &lt;strong&gt;you&lt;/strong&gt; see in one of your projects when&#xA;you run &lt;code&gt;git branch -a&lt;/code&gt;?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The following alias in your &lt;code&gt;~/.gitconfig&lt;/code&gt; will not only become second nature to&#xA;use when updating your base branch, but it&amp;rsquo;ll keep your environment tidy at the&#xA;same time.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;div style=&#34;color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&#xA;&lt;table style=&#34;border-spacing:0;padding:0;margin:0;border:0;&#34;&gt;&lt;tr&gt;&lt;td style=&#34;vertical-align:top;padding:0;margin:0;border:0;&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34; id=&#34;hl-0-1&#34;&gt;&lt;a style=&#34;outline:none;text-decoration:none;color:inherit&#34; href=&#34;#hl-0-1&#34;&gt;1&lt;/a&gt;&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34; id=&#34;hl-0-2&#34;&gt;&lt;a style=&#34;outline:none;text-decoration:none;color:inherit&#34; href=&#34;#hl-0-2&#34;&gt;2&lt;/a&gt;&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34; id=&#34;hl-0-3&#34;&gt;&lt;a style=&#34;outline:none;text-decoration:none;color:inherit&#34; href=&#34;#hl-0-3&#34;&gt;3&lt;/a&gt;&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34; id=&#34;hl-0-4&#34;&gt;&lt;a style=&#34;outline:none;text-decoration:none;color:inherit&#34; href=&#34;#hl-0-4&#34;&gt;4&lt;/a&gt;&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34; id=&#34;hl-0-5&#34;&gt;&lt;a style=&#34;outline:none;text-decoration:none;color:inherit&#34; href=&#34;#hl-0-5&#34;&gt;5&lt;/a&gt;&#xA;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#xA;&lt;td style=&#34;vertical-align:top;padding:0;margin:0;border:0;;width:100%&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;[alias]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    update-main = !git checkout main \&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &amp;amp;&amp;amp; git pull \&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &amp;amp;&amp;amp; git remote prune origin \&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &amp;amp;&amp;amp; git branch --merged | grep -v &amp;#34;\\\\*&amp;#34; | xargs -n 1 git branch -d&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;/div&gt;&lt;p&gt;Now any time you want to begin work on a new branch, first run &lt;code&gt;git update-main&lt;/code&gt;&#xA;to not only update your &lt;code&gt;main&lt;/code&gt; branch but also tidy your development&#xA;environment. Then checkout your new branch and get to work.&lt;/p&gt;&#xA;&lt;p&gt;It doesn&amp;rsquo;t really add any time to the process, has a lot of benefits by negating&#xA;the problems below, and eventually becomes second nature to use any time you&#xA;move over to a base branch.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; If your &lt;strong&gt;base branch&lt;/strong&gt; is different, such as &lt;code&gt;master&lt;/code&gt; or &lt;code&gt;develop&lt;/code&gt;,&#xA;add another instance of this alias with the proper replacements. Personally, I&#xA;have 3 instances covering &lt;code&gt;main&lt;/code&gt;, &lt;code&gt;master&lt;/code&gt;, and &lt;code&gt;staging&lt;/code&gt; which are often used&#xA;in teams I&amp;rsquo;ve been on.&lt;/p&gt;&#xA;&lt;p&gt;Once setup, they rarely change or need to be thought of again. I&amp;rsquo;ve been using&#xA;these since around 2013 and I&amp;rsquo;ve rarely given them a second thought other than&#xA;to share them with others.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h2 id=&#34;common-problems-with-a-messy-environment&#34;&gt;Common Problems with a Messy Environment&#xA;  &lt;a class=&#34;heading-link&#34; href=&#34;#common-problems-with-a-messy-environment&#34; title=&#34;Click to copy link&#34;&gt;&lt;i class=&#34;fas fa-link&#34;&gt;&lt;/i&gt;&lt;/a&gt;&#xA;&lt;/h2&gt;&#xA;&lt;h3 id=&#34;out-of-date-base-branch&#34;&gt;Out of Date Base Branch&#xA;  &lt;a class=&#34;heading-link&#34; href=&#34;#out-of-date-base-branch&#34; title=&#34;Click to copy link&#34;&gt;&lt;i class=&#34;fas fa-link&#34;&gt;&lt;/i&gt;&lt;/a&gt;&#xA;&lt;/h3&gt;&#xA;&lt;p&gt;How often have you completed work on a new feature and pushed your code to Github&#xA;only to find out your PR is &lt;em&gt;already out of date?&lt;/em&gt; How?! It&amp;rsquo;s a brand new PR!&lt;/p&gt;&#xA;&lt;p&gt;Well, it turns out locally &lt;em&gt;you forgot to update your base branch (&lt;code&gt;main&lt;/code&gt;)&#xA;before checking out a new branch to start work on your new feature.&lt;/em&gt; There&amp;rsquo;s a&#xA;high chance of this happening if you&amp;rsquo;re working within a team and commits are&#xA;landing in the base branch frequently.&lt;/p&gt;&#xA;&lt;p&gt;Though this is relatively inconsequential &lt;em&gt;most of the time,&lt;/em&gt; the worst case&#xA;would be that your code doesn&amp;rsquo;t work with the latest of the base branch at all!&#xA;Though this would hopefully be &lt;em&gt;very rare,&lt;/em&gt; it&amp;rsquo;s also easily avoided by keeping&#xA;your environment tidy.&lt;/p&gt;&#xA;&lt;h3 id=&#34;git-clutter--cognitive-load--lower-productivity&#34;&gt;Git Clutter == Cognitive Load &amp;amp; Lower Productivity&#xA;  &lt;a class=&#34;heading-link&#34; href=&#34;#git-clutter--cognitive-load--lower-productivity&#34; title=&#34;Click to copy link&#34;&gt;&lt;i class=&#34;fas fa-link&#34;&gt;&lt;/i&gt;&lt;/a&gt;&#xA;&lt;/h3&gt;&#xA;&lt;p&gt;Only slightly hyperbolic, a messy Git environment &lt;em&gt;does&lt;/em&gt; decrease your overall&#xA;productivity by making the tools you use to interact with Git slower to use.&#xA;Whether it&amp;rsquo;s tab completion or GUIs visualizing branches, keeping a lot of stale&#xA;or merged branches around adds no value and only presents downsides.&lt;/p&gt;&#xA;&lt;h2 id=&#34;alias-breakdown&#34;&gt;Alias Breakdown&#xA;  &lt;a class=&#34;heading-link&#34; href=&#34;#alias-breakdown&#34; title=&#34;Click to copy link&#34;&gt;&lt;i class=&#34;fas fa-link&#34;&gt;&lt;/i&gt;&lt;/a&gt;&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s go through some key points of some of the lines below for clarity and&#xA;understanding.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;div style=&#34;color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&#xA;&lt;table style=&#34;border-spacing:0;padding:0;margin:0;border:0;&#34;&gt;&lt;tr&gt;&lt;td style=&#34;vertical-align:top;padding:0;margin:0;border:0;&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34; id=&#34;hl-1-1&#34;&gt;&lt;a style=&#34;outline:none;text-decoration:none;color:inherit&#34; href=&#34;#hl-1-1&#34;&gt;1&lt;/a&gt;&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34; id=&#34;hl-1-2&#34;&gt;&lt;a style=&#34;outline:none;text-decoration:none;color:inherit&#34; href=&#34;#hl-1-2&#34;&gt;2&lt;/a&gt;&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34; id=&#34;hl-1-3&#34;&gt;&lt;a style=&#34;outline:none;text-decoration:none;color:inherit&#34; href=&#34;#hl-1-3&#34;&gt;3&lt;/a&gt;&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34; id=&#34;hl-1-4&#34;&gt;&lt;a style=&#34;outline:none;text-decoration:none;color:inherit&#34; href=&#34;#hl-1-4&#34;&gt;4&lt;/a&gt;&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34; id=&#34;hl-1-5&#34;&gt;&lt;a style=&#34;outline:none;text-decoration:none;color:inherit&#34; href=&#34;#hl-1-5&#34;&gt;5&lt;/a&gt;&#xA;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#xA;&lt;td style=&#34;vertical-align:top;padding:0;margin:0;border:0;;width:100%&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;[alias]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    update-main = !git checkout main \&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &amp;amp;&amp;amp; git pull \&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &amp;amp;&amp;amp; git remote prune origin \&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &amp;amp;&amp;amp; git branch --merged | grep -v &amp;#34;\\\\*&amp;#34; | xargs -n 1 git branch -d&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;/div&gt;&lt;h3 id=&#34;running-shell-commands-with-&#34;&gt;Running Shell Commands with &lt;code&gt;!&lt;/code&gt;&#xA;  &lt;a class=&#34;heading-link&#34; href=&#34;#running-shell-commands-with-&#34; title=&#34;Click to copy link&#34;&gt;&lt;i class=&#34;fas fa-link&#34;&gt;&lt;/i&gt;&lt;/a&gt;&#xA;&lt;/h3&gt;&#xA;&lt;p&gt;By default every alias is expected to be a &lt;em&gt;Git command.&lt;/em&gt; If you want to call&#xA;&lt;code&gt;git&lt;/code&gt; itself, you need to prefix the call with &lt;code&gt;!&lt;/code&gt; to indicate it should be&#xA;calling a &lt;em&gt;shell command&lt;/em&gt; instead of a Git command. So &lt;code&gt;!git checkout main&lt;/code&gt; at&#xA;the start of the alias will ensure it and the rest of the commands run as &lt;em&gt;shell&#xA;commands.&lt;/em&gt; No more &lt;code&gt;git: &#39;git&#39; is not a git command.&lt;/code&gt; errors.&lt;/p&gt;&#xA;&lt;h3 id=&#34;pruning-remote-branches&#34;&gt;Pruning Remote Branches&#xA;  &lt;a class=&#34;heading-link&#34; href=&#34;#pruning-remote-branches&#34; title=&#34;Click to copy link&#34;&gt;&lt;i class=&#34;fas fa-link&#34;&gt;&lt;/i&gt;&lt;/a&gt;&#xA;&lt;/h3&gt;&#xA;&lt;p&gt;Over time branches will often be deleted from the remote origin during the&#xA;natural development process. Your development environment however will not be kept up&#xA;to date without either the right default configurations or manual calls as I&amp;rsquo;m&#xA;using here. &lt;code&gt;git remote prune origin&lt;/code&gt; will just ensure that any deleted remote&#xA;branches are cleared from your development environment as well.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Everything in this process works &lt;em&gt;best&lt;/em&gt; if you &lt;strong&gt;delete remote&#xA;branches after they&amp;rsquo;re merged.&lt;/strong&gt; Though not fully required, there is &lt;em&gt;no&#xA;benefit&lt;/em&gt; to keeping merged remote branches around.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h3 id=&#34;pruning-merged-local-branches&#34;&gt;Pruning &lt;em&gt;Merged&lt;/em&gt; Local Branches&#xA;  &lt;a class=&#34;heading-link&#34; href=&#34;#pruning-merged-local-branches&#34; title=&#34;Click to copy link&#34;&gt;&lt;i class=&#34;fas fa-link&#34;&gt;&lt;/i&gt;&lt;/a&gt;&#xA;&lt;/h3&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;div style=&#34;color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&#xA;&lt;table style=&#34;border-spacing:0;padding:0;margin:0;border:0;&#34;&gt;&lt;tr&gt;&lt;td style=&#34;vertical-align:top;padding:0;margin:0;border:0;&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34; id=&#34;hl-2-1&#34;&gt;&lt;a style=&#34;outline:none;text-decoration:none;color:inherit&#34; href=&#34;#hl-2-1&#34;&gt;1&lt;/a&gt;&#xA;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#xA;&lt;td style=&#34;vertical-align:top;padding:0;margin:0;border:0;;width:100%&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;git branch --merged | grep -v &amp;#34;\\\\*&amp;#34; | xargs -n 1 git branch -d&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;/div&gt;&lt;p&gt;This is an interesting line in that it&amp;rsquo;s listing out all local branches that&#xA;have &lt;em&gt;no changes from the current branch&lt;/em&gt; and then deletes them. &lt;code&gt;grep -v &amp;quot;\\\\*&amp;quot;&lt;/code&gt; is filtering &lt;strong&gt;out&lt;/strong&gt; the &lt;em&gt;current branch&lt;/em&gt; from the output of &lt;code&gt;git branch --merged&lt;/code&gt; so that any other lines can be fed to the delete command.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;This works best when run from the &lt;em&gt;base branch&lt;/em&gt; you&amp;rsquo;re updating (&lt;code&gt;main&lt;/code&gt;)&lt;/strong&gt;&#xA;so using it within this alias is recommended. There&amp;rsquo;s no harm if it removes&#xA;the local instance of &lt;code&gt;main&lt;/code&gt; however, as it will just be re-checked out from&#xA;remote the next time you need it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;I hope this alias, and some of the backing information, is useful to your every&#xA;day development. &lt;em&gt;There&amp;rsquo;s always something new and shiny in the world of&#xA;software&lt;/em&gt; but I always find it interesting to reflect on those little things set&#xA;up over a decade ago that are still used dozens of times per day and now&#xA;couldn&amp;rsquo;t be lived without.&lt;/p&gt;&#xA;&lt;p&gt;Progress &amp;amp; productivity doesn&amp;rsquo;t always have to be a search for a new tool or&#xA;dependency, &lt;strong&gt;sometimes it&amp;rsquo;s just stitching together various commands into an&#xA;alias that fits your flow, reduces mistakes, and makes your environment more&#xA;enjoyable to work in.&lt;/strong&gt;&lt;/p&gt;&#xA;</description>
    </item>
  </channel>
</rss>
