<?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>DEV Community: Wojciech Korzeniowski</title>
    <description>The latest articles on DEV Community by Wojciech Korzeniowski (@wojciechko).</description>
    <link>https://dev.to/wojciechko</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%2F365784%2F1e0644b7-4d95-44e8-afce-4fcaf1e74df7.jpeg</url>
      <title>DEV Community: Wojciech Korzeniowski</title>
      <link>https://dev.to/wojciechko</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/wojciechko"/>
    <language>en</language>
    <item>
      <title>Git alias to delete merged branches</title>
      <dc:creator>Wojciech Korzeniowski</dc:creator>
      <pubDate>Mon, 13 Apr 2020 14:21:05 +0000</pubDate>
      <link>https://dev.to/wojciechko/git-alias-to-delete-merged-branches-3cop</link>
      <guid>https://dev.to/wojciechko/git-alias-to-delete-merged-branches-3cop</guid>
      <description>&lt;p&gt;When you develop a project using multiple branches you may end up with a situation where you have branches which have already been merged into another branch and now serve no purpose.&lt;/p&gt;

&lt;p&gt;I've created a git alias that deletes every branch that is already merged into &lt;code&gt;master&lt;/code&gt; or another branch provided as an argument. To use it you need to modify &lt;code&gt;.gitconfig&lt;/code&gt; and add following lines into it&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[alias]
  cleanup = "!f() { git branch --merged ${1:-master} | egrep -v \"(^\\*|${1:-master})\" | xargs --no-run-if-empty git branch -d; };f"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can execute given command inside your terminal to achieve the same effect&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git config --global alias.cleanup '!f() { git branch --merged ${1:-master} | egrep -v "(^\*|${1:-master})" | xargs --no-run-if-empty git branch -d; };f'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Then you can remove branches merged into &lt;code&gt;master&lt;/code&gt; by invoking &lt;code&gt;git cleanup&lt;/code&gt;. You can also provide a branch as an argument if your want to clean up a different branch eg. &lt;code&gt;git cleanup development&lt;/code&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>bash</category>
    </item>
  </channel>
</rss>
