{"id":7187,"date":"2014-08-11T10:33:26","date_gmt":"2014-08-11T07:33:26","guid":{"rendered":"http:\/\/railsware.com\/blog\/?p=7187"},"modified":"2023-05-14T16:47:17","modified_gmt":"2023-05-14T13:47:17","slug":"git-clean-up-in-local-and-remote-branches","status":"publish","type":"post","link":"https:\/\/railsware.com\/blog\/git-clean-up-in-local-and-remote-branches\/","title":{"rendered":"Git Clean-up in Local and Remote Branches, Repositories"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">After working with branch per feature for a while any Git-repository becomes a mess of outdated and not finished branches.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To deal with this issue, <strong>we need to clean-up three kinds of branches<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Local branches &#8211; our day-to-day working branches<\/li>\n\n\n\n<li>References to remote branches &#8211; aka origin\/branch-name items<\/li>\n\n\n\n<li>Actual remote branches &#8211; branches on remote server(e.g.: github, bitbucket, gitorius)<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">In this tutorial we suppose, that &#8220;master&#8221; &#8211; is a default branch, where everything is merged (for someone it could be &#8220;develop&#8221;, or &#8220;release&#8221; branch), and &#8220;origin&#8221; &#8211; it&#8217;s a name of remote. If you use different names, just change them in appropriate commands.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Local branches<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">At first, list all local branches:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted toolbar:2 wrap:true theme:tomorrow-night lang:sh nums:false\">$ git branch\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">We need to know what branches are already merged in &#8220;master&#8221; and can be easily removed:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted toolbar:2 wrap:true theme:tomorrow-night lang:sh nums:false\">$ git checkout master\n$ git branch --merged\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now, remove all outdated branches with:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted toolbar:2 wrap:true theme:tomorrow-night lang:sh nums:false\">$ git branch -d old-merged-feature\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Next, decide what to do with not merged branches:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted toolbar:2 wrap:true theme:tomorrow-night lang:sh nums:false\">$ git branch --no-merged\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If some of them is just abandoned stuff that you don&#8217;t need anymore, remove it with &#8220;-D&#8221; option:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted toolbar:2 wrap:true theme:tomorrow-night lang:sh nums:false\">$ git branch -D old-abandoned-feature\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">References to remote branches<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After each <span class=\"lang:ruby crayon-inline\">git pull<\/span> or <span class=\"lang:ruby crayon-inline\">git fetch<\/span> command Git creates references to remote branches in local repository, but doesn&#8217;t clean up stale references.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">List referenced remote branches:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted toolbar:2 wrap:true theme:tomorrow-night lang:sh nums:false\">$ git branch -r\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Clean-up outdated references:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted toolbar:2 wrap:true theme:tomorrow-night lang:sh nums:false\">$ git remote prune origin\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Tip<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Update repository with:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted toolbar:2 wrap:true theme:tomorrow-night lang:sh nums:false\">$ git fetch -p\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">and Git automatically prunes all stale references.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Remote branches<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Usually, remote repository is a big garbage heap of stale branches, if there is no responsible housekeeping person.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After previous <span class=\"lang:ruby crayon-inline\">git remote prune origin<\/span> we should have synched list of remote branches.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">At first, we can find branches which are already merged in &#8220;master&#8221;:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted toolbar:2 wrap:true theme:tomorrow-night lang:sh nums:false\">$ git checkout master\n$ git branch -r --merged\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">But this command does not provide much information. What if this branch is merged, but still used for feature development. Would be cool to know last commit date and author.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This magic snippet provides all required information:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted toolbar:2 wrap:true theme:tomorrow-night lang:sh nums:false\">$ for branch in `git branch -r --merged | grep -v HEAD`; do echo -e `git show --format=\"%ci %cr %an\" $branch | head -n 1` \\\\t$branch; done | sort -r\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now, you can delete own remote branches, and ask other authors to clean-up theirs:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted toolbar:2 wrap:true theme:tomorrow-night lang:sh nums:false\">$ git push origin --delete branch-name\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Similar snippet for not merged branches:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted toolbar:2 wrap:true theme:tomorrow-night lang:sh nums:false\">$ for branch in `git branch -r --no-merged | grep -v HEAD`; do echo -e `git show --format=\"%ci %cr %an\" $branch | head -n 1` \\\\t$branch; done | sort -r\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This list should be reviewed more thoroughly to avoid losing important commits.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Tip for Github users<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">After the last Github update, <strong>Branches<\/strong> page is divided into &#8220;Your branches&#8221;, &#8220;Active branches&#8221; and &#8220;Stale branches&#8221;, and it shows same information as previous commands.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Bonus snippets<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Usually, it&#8217;s simple to remove local and appropriate remote branches at once.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This snippet shows only local merged branches, which have appropriate remote merged branches:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted toolbar:2 wrap:true theme:tomorrow-night lang:sh nums:false\">$ comm -12  &lt;(git branch --merged|awk '{print($1)}') &lt;(git branch -r --merged|awk '{print($1)}'|awk -F \\\/ '{print($2)}')\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">More hardcore snippet with date and author information:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted toolbar:2 wrap:true theme:tomorrow-night lang:sh nums:false\">$ for branch in `comm -12  &lt;(git branch --merged|awk '{print($1)}') &lt;(git branch -r --merged|awk '{print($1)}'|awk -F \\\/ '{print($2)}')`;do echo -e `git show --format=\"%ci %cr %an\" $branch | head -n 1` \\\\t$branch; done | sort -r\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Same snippets for not merged branches:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted toolbar:2 wrap:true theme:tomorrow-night lang:sh nums:false\">$ comm -12  &lt;(git branch --no-merged|awk '{print($1)}') &lt;(git branch -r --no-merged|awk '{print($1)}'|awk -F \\\/ '{print($2)}')\n<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted toolbar:2 wrap:true theme:tomorrow-night lang:sh nums:false\">$ for branch in `comm -12  &lt;(git branch --no-merged|awk '{print($1)}') &lt;(git branch -r --no-merged|awk '{print($1)}'|awk -F \\\/ '{print($2)}')`; do echo -e `git show --format=\"%ci %cr %an\" $branch | head -n 1` \\\\t$branch; done | sort -r\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Moving stuff into .gitconfig<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It&#8217;s hard to remember such code, so the best way is to create shell scripts and put them in local &#8220;bin&#8221; folder. Note that these snippets work only in bash(and zsh). For example, let&#8217;s put first snippet into &#8220;bin\/git-both-merged&#8221; file:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted wrap:true lang:sh\">#!\/usr\/bin\/env bash\n\ncomm -12  &lt;(git branch --merged|awk '{print($1)}') &lt;(git branch -r --merged|awk '{print($1)}'|awk -F \\\/ '{print($2)}')\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Don&#8217;t forget to make it executable(<span class=\"lang:sh crayon-inline\">chmod 755 git-both-merged<\/span>), and you can also make a git alias for this script. Put next line in .gitconfig:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[alias]\n  # ... other aliases\n  both-merged = !git-both-merged\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now you can call it via git command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted toolbar:2 wrap:true theme:tomorrow-night lang:sh nums:false\">$ git both-merged\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In the same vein you can create git aliases for all snippets from this article.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That&#8217;s it, folks. Now, it&#8217;s time to clean-up all stale stuff!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After working with branch per feature for a while any Git-repository becomes a mess of outdated and not finished branches. To deal with this issue, we need to clean-up three kinds of branches: In this tutorial we suppose, that &#8220;master&#8221; &#8211; is a default branch, where everything is merged (for someone it could be &#8220;develop&#8221;,&#8230;<\/p>\n","protected":false},"author":25,"featured_media":9453,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[3],"tags":[],"coauthors":["Sergii Boiko"],"class_list":["post-7187","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-development"],"acf":[],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.9 - aioseo.com -->\n\t<meta name=\"description\" content=\"After working with branch per feature for a while any Git-repository becomes a mess of outdated and not finished branches. To deal with this issue, we need to clean-up three kinds of branches: Local branches - our day-to-day working branches References to remote branches - aka origin\/branch-name items Actual remote branches - branches on remote\" \/>\n\t<meta name=\"robots\" content=\"max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n\t<meta name=\"author\" content=\"Sergii Boiko\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/railsware.com\/blog\/git-clean-up-in-local-and-remote-branches\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.9\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"| Blog on Engineering, Product Management, Transparency, Culture and many more...\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Git Clean-up in Local and Remote Branches, Repositories | Railsware Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"After working with branch per feature for a while any Git-repository becomes a mess of outdated and not finished branches. To deal with this issue, we need to clean-up three kinds of branches: Local branches - our day-to-day working branches References to remote branches - aka origin\/branch-name items Actual remote branches - branches on remote\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/railsware.com\/blog\/git-clean-up-in-local-and-remote-branches\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/Git-housekeeping.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/Git-housekeeping.png\" \/>\n\t\t<meta property=\"og:image:width\" content=\"360\" \/>\n\t\t<meta property=\"og:image:height\" content=\"360\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2014-08-11T07:33:26+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2023-05-14T13:47:17+00:00\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/git-clean-up-in-local-and-remote-branches\\\/#article\",\"name\":\"Git Clean-up in Local and Remote Branches, Repositories | Railsware Blog\",\"headline\":\"Git Clean-up in Local and Remote Branches, Repositories\",\"author\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/author\\\/sergii-boiko\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/12\\\/Git-housekeeping.png\",\"width\":360,\"height\":360,\"caption\":\"Git clean-up tutorial\"},\"datePublished\":\"2014-08-11T10:33:26+03:00\",\"dateModified\":\"2023-05-14T16:47:17+03:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/git-clean-up-in-local-and-remote-branches\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/git-clean-up-in-local-and-remote-branches\\\/#webpage\"},\"articleSection\":\"Engineering\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/git-clean-up-in-local-and-remote-branches\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/railsware.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/category\\\/development\\\/#listItem\",\"name\":\"Engineering\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/category\\\/development\\\/#listItem\",\"position\":2,\"name\":\"Engineering\",\"item\":\"https:\\\/\\\/railsware.com\\\/blog\\\/category\\\/development\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/git-clean-up-in-local-and-remote-branches\\\/#listItem\",\"name\":\"Git Clean-up in Local and Remote Branches, Repositories\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/git-clean-up-in-local-and-remote-branches\\\/#listItem\",\"position\":3,\"name\":\"Git Clean-up in Local and Remote Branches, Repositories\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/category\\\/development\\\/#listItem\",\"name\":\"Engineering\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/#organization\",\"description\":\"Blog on Engineering, Product Management, Transparency, Culture and many more...\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/Logo-circle.png\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/git-clean-up-in-local-and-remote-branches\\\/#organizationLogo\",\"width\":3137,\"height\":1054,\"caption\":\"Railsware logo\"},\"image\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/git-clean-up-in-local-and-remote-branches\\\/#organizationLogo\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/author\\\/sergii-boiko\\\/#author\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/author\\\/sergii-boiko\\\/\",\"name\":\"Sergii Boiko\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/git-clean-up-in-local-and-remote-branches\\\/#authorImage\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/06\\\/sergii-boiko-96x96.jpg\",\"width\":96,\"height\":96,\"caption\":\"Sergii Boiko\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/git-clean-up-in-local-and-remote-branches\\\/#webpage\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/git-clean-up-in-local-and-remote-branches\\\/\",\"name\":\"Git Clean-up in Local and Remote Branches, Repositories | Railsware Blog\",\"description\":\"After working with branch per feature for a while any Git-repository becomes a mess of outdated and not finished branches. To deal with this issue, we need to clean-up three kinds of branches: Local branches - our day-to-day working branches References to remote branches - aka origin\\\/branch-name items Actual remote branches - branches on remote\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/git-clean-up-in-local-and-remote-branches\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/author\\\/sergii-boiko\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/author\\\/sergii-boiko\\\/#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/12\\\/Git-housekeeping.png\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/git-clean-up-in-local-and-remote-branches\\\/#mainImage\",\"width\":360,\"height\":360,\"caption\":\"Git clean-up tutorial\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/git-clean-up-in-local-and-remote-branches\\\/#mainImage\"},\"datePublished\":\"2014-08-11T10:33:26+03:00\",\"dateModified\":\"2023-05-14T16:47:17+03:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/\",\"description\":\"Blog on Engineering, Product Management, Transparency, Culture and many more...\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Git Clean-up in Local and Remote Branches, Repositories | Railsware Blog","description":"After working with branch per feature for a while any Git-repository becomes a mess of outdated and not finished branches. To deal with this issue, we need to clean-up three kinds of branches: Local branches - our day-to-day working branches References to remote branches - aka origin\/branch-name items Actual remote branches - branches on remote","canonical_url":"https:\/\/railsware.com\/blog\/git-clean-up-in-local-and-remote-branches\/","robots":"max-snippet:-1, max-image-preview:large, max-video-preview:-1","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/railsware.com\/blog\/git-clean-up-in-local-and-remote-branches\/#article","name":"Git Clean-up in Local and Remote Branches, Repositories | Railsware Blog","headline":"Git Clean-up in Local and Remote Branches, Repositories","author":{"@id":"https:\/\/railsware.com\/blog\/author\/sergii-boiko\/#author"},"publisher":{"@id":"https:\/\/railsware.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/Git-housekeeping.png","width":360,"height":360,"caption":"Git clean-up tutorial"},"datePublished":"2014-08-11T10:33:26+03:00","dateModified":"2023-05-14T16:47:17+03:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/railsware.com\/blog\/git-clean-up-in-local-and-remote-branches\/#webpage"},"isPartOf":{"@id":"https:\/\/railsware.com\/blog\/git-clean-up-in-local-and-remote-branches\/#webpage"},"articleSection":"Engineering"},{"@type":"BreadcrumbList","@id":"https:\/\/railsware.com\/blog\/git-clean-up-in-local-and-remote-branches\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/railsware.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog\/category\/development\/#listItem","name":"Engineering"}},{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog\/category\/development\/#listItem","position":2,"name":"Engineering","item":"https:\/\/railsware.com\/blog\/category\/development\/","nextItem":{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog\/git-clean-up-in-local-and-remote-branches\/#listItem","name":"Git Clean-up in Local and Remote Branches, Repositories"},"previousItem":{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog\/git-clean-up-in-local-and-remote-branches\/#listItem","position":3,"name":"Git Clean-up in Local and Remote Branches, Repositories","previousItem":{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog\/category\/development\/#listItem","name":"Engineering"}}]},{"@type":"Organization","@id":"https:\/\/railsware.com\/blog\/#organization","description":"Blog on Engineering, Product Management, Transparency, Culture and many more...","url":"https:\/\/railsware.com\/blog\/","logo":{"@type":"ImageObject","url":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2020\/11\/Logo-circle.png","@id":"https:\/\/railsware.com\/blog\/git-clean-up-in-local-and-remote-branches\/#organizationLogo","width":3137,"height":1054,"caption":"Railsware logo"},"image":{"@id":"https:\/\/railsware.com\/blog\/git-clean-up-in-local-and-remote-branches\/#organizationLogo"}},{"@type":"Person","@id":"https:\/\/railsware.com\/blog\/author\/sergii-boiko\/#author","url":"https:\/\/railsware.com\/blog\/author\/sergii-boiko\/","name":"Sergii Boiko","image":{"@type":"ImageObject","@id":"https:\/\/railsware.com\/blog\/git-clean-up-in-local-and-remote-branches\/#authorImage","url":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2021\/06\/sergii-boiko-96x96.jpg","width":96,"height":96,"caption":"Sergii Boiko"}},{"@type":"WebPage","@id":"https:\/\/railsware.com\/blog\/git-clean-up-in-local-and-remote-branches\/#webpage","url":"https:\/\/railsware.com\/blog\/git-clean-up-in-local-and-remote-branches\/","name":"Git Clean-up in Local and Remote Branches, Repositories | Railsware Blog","description":"After working with branch per feature for a while any Git-repository becomes a mess of outdated and not finished branches. To deal with this issue, we need to clean-up three kinds of branches: Local branches - our day-to-day working branches References to remote branches - aka origin\/branch-name items Actual remote branches - branches on remote","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/railsware.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/railsware.com\/blog\/git-clean-up-in-local-and-remote-branches\/#breadcrumblist"},"author":{"@id":"https:\/\/railsware.com\/blog\/author\/sergii-boiko\/#author"},"creator":{"@id":"https:\/\/railsware.com\/blog\/author\/sergii-boiko\/#author"},"image":{"@type":"ImageObject","url":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/Git-housekeeping.png","@id":"https:\/\/railsware.com\/blog\/git-clean-up-in-local-and-remote-branches\/#mainImage","width":360,"height":360,"caption":"Git clean-up tutorial"},"primaryImageOfPage":{"@id":"https:\/\/railsware.com\/blog\/git-clean-up-in-local-and-remote-branches\/#mainImage"},"datePublished":"2014-08-11T10:33:26+03:00","dateModified":"2023-05-14T16:47:17+03:00"},{"@type":"WebSite","@id":"https:\/\/railsware.com\/blog\/#website","url":"https:\/\/railsware.com\/blog\/","description":"Blog on Engineering, Product Management, Transparency, Culture and many more...","inLanguage":"en-US","publisher":{"@id":"https:\/\/railsware.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"| Blog on Engineering, Product Management, Transparency, Culture and many more...","og:type":"article","og:title":"Git Clean-up in Local and Remote Branches, Repositories | Railsware Blog","og:description":"After working with branch per feature for a while any Git-repository becomes a mess of outdated and not finished branches. To deal with this issue, we need to clean-up three kinds of branches: Local branches - our day-to-day working branches References to remote branches - aka origin\/branch-name items Actual remote branches - branches on remote","og:url":"https:\/\/railsware.com\/blog\/git-clean-up-in-local-and-remote-branches\/","og:image":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/Git-housekeeping.png","og:image:secure_url":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/Git-housekeeping.png","og:image:width":360,"og:image:height":360,"article:published_time":"2014-08-11T07:33:26+00:00","article:modified_time":"2023-05-14T13:47:17+00:00"},"aioseo_meta_data":{"post_id":"7187","title":"Git Clean-up in Local and Remote Branches, Repositories | Railsware Blog","description":null,"keywords":[],"keyphrases":{"focus":{"keyphrase":"","score":0,"analysis":{"keyphraseInTitle":{"score":0,"maxScore":9,"error":1}}},"additional":[]},"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":[],"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":{"id":"aioseo-article-6385f91125b9d","slug":"article","graphName":"Article","label":"Article","properties":{"type":"BlogPosting","name":"#post_title","headline":"#post_title","description":"#post_excerpt","image":"","keywords":"","author":{"name":"#author_name","url":"#author_url"},"dates":{"include":true,"datePublished":"","dateModified":""}}},"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":"{\"article\":{\"articleType\":\"BlogPosting\"},\"course\":{\"name\":\"\",\"description\":\"\",\"provider\":\"\"},\"faq\":{\"pages\":[]},\"product\":{\"reviews\":[]},\"recipe\":{\"ingredients\":[],\"instructions\":[],\"keywords\":[]},\"software\":{\"reviews\":[],\"operatingSystems\":[]},\"webPage\":{\"webPageType\":\"WebPage\"}}","pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","location":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2021-01-04 12:44:30","updated":"2025-09-26 11:22:38","seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/railsware.com\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/railsware.com\/blog\/category\/development\/\" title=\"Engineering\">Engineering<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tGit Clean-up in Local and Remote Branches, Repositories\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/railsware.com\/blog"},{"label":"Engineering","link":"https:\/\/railsware.com\/blog\/category\/development\/"},{"label":"Git Clean-up in Local and Remote Branches, Repositories","link":"https:\/\/railsware.com\/blog\/git-clean-up-in-local-and-remote-branches\/"}],"categories_data":[{"name":"Engineering","link":"https:\/\/railsware.com\/blog?category=development"}],"post_thumbnails":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/Git-housekeeping.png","article_background":"","amp_enabled":true,"_links":{"self":[{"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/posts\/7187","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/users\/25"}],"replies":[{"embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/comments?post=7187"}],"version-history":[{"count":25,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/posts\/7187\/revisions"}],"predecessor-version":[{"id":16282,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/posts\/7187\/revisions\/16282"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/media\/9453"}],"wp:attachment":[{"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/media?parent=7187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/categories?post=7187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/tags?post=7187"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/coauthors?post=7187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}