{"id":714,"date":"2023-10-07T10:23:05","date_gmt":"2023-10-07T08:23:05","guid":{"rendered":"https:\/\/blog.chloesoe.ch\/?p=714"},"modified":"2025-01-21T09:20:28","modified_gmt":"2025-01-21T07:20:28","slug":"git-command-collection","status":"publish","type":"post","link":"https:\/\/blog.chloesoe.ch\/?p=714","title":{"rendered":"Git Command Collection"},"content":{"rendered":"<h1>Overview<\/h1>\n<p>This page should be a collection of useful git commands I usually forget about<\/p>\n<h1>Commands<\/h1>\n<h2>Find branches ordered by last commit date<\/h2>\n<pre><code class=\"language-bash\">git for-each-ref --sort=committerdate refs\/heads\/ --format=&#039;%(committerdate:short) %(refname:short)&#039;<\/code><\/pre>\n<p><a href=\"https:\/\/stackoverflow.com\/a\/16961359\/7311363\">https:\/\/stackoverflow.com\/a\/16961359\/7311363<\/a><\/p>\n<h2>Delete local branches<\/h2>\n<pre><code class=\"language-bash\"># Remove information on branches that were deleted on origin (https:\/\/stackoverflow.com\/a\/5751635\/7311363)\n\ngit fetch --prune\n\n# or according to https:\/\/stackoverflow.com\/a\/8766540\/7311363\n\ngit remote prune origin\n\n# remove local branches that are not longer relevant according to https:\/\/stackoverflow.com\/a\/18380712\/7311363\n\ngit branch --merged origin\/master | xargs git branch -d\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Overview This page should be a collection of useful git commands I usually forget about Commands Find branches ordered by last commit date git for-each-ref &#8211;sort=committerdate refs\/heads\/ &#8211;format=&#039;%(committerdate:short) %(refname:short)&#039; https:\/\/stackoverflow.com\/a\/16961359\/7311363 Delete local branches # Remove information on branches that were deleted on origin (https:\/\/stackoverflow.com\/a\/5751635\/7311363) git fetch &#8211;prune # or according to https:\/\/stackoverflow.com\/a\/8766540\/7311363 git remote prune&#8230; <a href=\"https:\/\/blog.chloesoe.ch\/?p=714\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Git Command Collection<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[],"class_list":["post-714","post","type-post","status-publish","format-standard","hentry","category-git"],"_links":{"self":[{"href":"https:\/\/blog.chloesoe.ch\/index.php?rest_route=\/wp\/v2\/posts\/714","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.chloesoe.ch\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.chloesoe.ch\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.chloesoe.ch\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.chloesoe.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=714"}],"version-history":[{"count":11,"href":"https:\/\/blog.chloesoe.ch\/index.php?rest_route=\/wp\/v2\/posts\/714\/revisions"}],"predecessor-version":[{"id":774,"href":"https:\/\/blog.chloesoe.ch\/index.php?rest_route=\/wp\/v2\/posts\/714\/revisions\/774"}],"wp:attachment":[{"href":"https:\/\/blog.chloesoe.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=714"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.chloesoe.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=714"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.chloesoe.ch\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=714"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}