<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Daniel Teixeira</title>
    <description>The latest articles on Forem by Daniel Teixeira (@dsteixeira).</description>
    <link>https://forem.com/dsteixeira</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1786836%2F5cc2efb3-a3a7-4747-93b1-1f17b5257087.jpg</url>
      <title>Forem: Daniel Teixeira</title>
      <link>https://forem.com/dsteixeira</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/dsteixeira"/>
    <language>en</language>
    <item>
      <title>Remove local branches that are no longer in the origin</title>
      <dc:creator>Daniel Teixeira</dc:creator>
      <pubDate>Tue, 04 Feb 2025 17:54:52 +0000</pubDate>
      <link>https://forem.com/dsteixeira/remove-local-branches-that-are-no-longer-in-the-origin-cdd</link>
      <guid>https://forem.com/dsteixeira/remove-local-branches-that-are-no-longer-in-the-origin-cdd</guid>
      <description>&lt;p&gt;This is a simple script that I use to remove local branches that are no longer on the origin. Just to clean my local env.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git remote prune origin
git branch -vv | grep ': gone]' | grep -v "\*" | awk '{ print $1; }' | xargs -r git branch -d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also create an &lt;a href="https://www.redhat.com/en/blog/how-create-alias-linux" rel="noopener noreferrer"&gt;alias&lt;/a&gt; and add to your &lt;strong&gt;.bashrc&lt;/strong&gt; (if you use Linux or macOS).&lt;/p&gt;

&lt;p&gt;Edit ~/.bashrc file.&lt;/p&gt;

&lt;p&gt;Add this in the end of the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alias git-clean="git remote prune origin; git branch -vv | grep ': gone]' | grep -v \"\*\" | awk '{ print $1; }' | xargs -r git branch -d;"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reload bash: source ~/.bashrc&lt;/p&gt;

&lt;p&gt;That's all. :)&lt;/p&gt;

</description>
      <category>git</category>
      <category>development</category>
      <category>script</category>
    </item>
  </channel>
</rss>
