{"id":1351,"date":"2018-05-16T09:51:53","date_gmt":"2018-05-16T15:51:53","guid":{"rendered":"http:\/\/jaredrobinson.com\/blog\/?p=1351"},"modified":"2018-05-16T09:51:53","modified_gmt":"2018-05-16T15:51:53","slug":"show-which-git-branches-have-been-merged-and-can-be-deleted","status":"publish","type":"post","link":"https:\/\/jaredrobinson.com\/blog\/show-which-git-branches-have-been-merged-and-can-be-deleted\/","title":{"rendered":"Show which git branches have been merged and can be deleted"},"content":{"rendered":"<p>At work, we generate quite a few feature branches, which get tested, and then merge into &#8220;develop&#8221;. The feature branches don&#8217;t get cleaned up frequently. Here&#8217;s a series of shell commands I cobbled together to show the most recent person to commit to the branch, and which branches have been merged into develop.<\/p>\n<pre><code>git checkout develop\ngit pull -r\n(for branch in $(git branch -r --merged | grep -vP \"release|develop|master\") ; do git log -1 --pretty=format:'%an' $branch | cat ; echo \" $branch\" ; done) | sort | sed -e 's#origin\/##'\n<\/code><\/pre>\n<p>The output looks something like this:<\/p>\n<pre><code>Jane Doe feature\/something\nJane Doe feature\/another-thing\nJane Doe feature\/yet-another-something\nZane Ears feature\/howdy\n<\/code><\/pre>\n<p>And they can be deleted as follows:<\/p>\n<pre><code>git push origin --delete feature\/something\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>At work, we generate quite a few feature branches, which get tested, and then merge into &#8220;develop&#8221;. The feature branches don&#8217;t get cleaned up frequently. Here&#8217;s a series of shell commands I cobbled together to show the most recent person to commit to the branch, and which branches have been merged into develop. git checkout &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/jaredrobinson.com\/blog\/show-which-git-branches-have-been-merged-and-can-be-deleted\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Show which git branches have been merged and can be deleted&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,17,30,19],"tags":[],"class_list":["post-1351","post","type-post","status-publish","format-standard","hentry","category-programming","category-tech","category-tools","category-work"],"_links":{"self":[{"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/posts\/1351","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/comments?post=1351"}],"version-history":[{"count":2,"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/posts\/1351\/revisions"}],"predecessor-version":[{"id":1354,"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/posts\/1351\/revisions\/1354"}],"wp:attachment":[{"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/media?parent=1351"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/categories?post=1351"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/tags?post=1351"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}