{"id":5497,"date":"2019-08-08T19:22:32","date_gmt":"2019-08-09T00:22:32","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=5497"},"modified":"2019-08-08T19:22:32","modified_gmt":"2019-08-09T00:22:32","slug":"renaming-a-branch-in-git","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=5497","title":{"rendered":"Renaming a Branch in Git"},"content":{"rendered":"<p>I finally had a situation where I needed to rename a branch in git. When I was the only one involved in a development effort (or even looking at it!), it didn&#8217;t really matter if I typo&#8217;d something. Exchange and Exchagne &#8230; I know what I meant. But working under a more formal development process, I started naming my branch after the issue ID. And managed to typo the <em>first one<\/em>. Sigh!<\/p>\n<p># Check out the incorrectly named branch<\/p>\n<p><strong>git checkout OSSA166<\/strong><\/p>\n<p># Rename it with the correct name<\/p>\n<p><strong>git branch -m OSSA163<\/strong><\/p>\n<p># See what you&#8217;ve got &#8212; the local one is right now, but the remote is still incorrectly named<\/p>\n<p><strong>git branch -a<\/strong><\/p>\n<p>* OSSA163<br \/>\nmaster<br \/>\nremotes\/origin\/HEAD -&gt; origin\/master<br \/>\nremotes\/origin\/OSSA166<br \/>\nremotes\/origin\/master<br \/>\nremotes\/origin\/uat<\/p>\n<p># Push a change to rename the remote one too<\/p>\n<p><strong>git push origin :OSSA166 OSSA163<\/strong><\/p>\n<p>Total 0 (delta 0), reused 0 (delta 0)<\/p>\n<p>To ssh:\/\/git.example.com\/path\/to\/my\/repo.git<\/p>\n<p>&#8211; [deleted] \u00a0 \u00a0 \u00a0 \u00a0 OSSA166<br \/>\n* [new branch] \u00a0 \u00a0 \u00a0OSSA163 -&gt; OSSA163<\/p>\n<p># And see what you&#8217;ve got again<\/p>\n<p><strong>git branch -a<\/strong><\/p>\n<p>* OSSA163<br \/>\nmaster<br \/>\nremotes\/origin\/HEAD -&gt; origin\/master<br \/>\nremotes\/origin\/OSSA163<br \/>\nremotes\/origin\/master<br \/>\nremotes\/origin\/uat<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I finally had a situation where I needed to rename a branch in git. When I was the only one involved in a development effort (or even looking at it!), it didn&#8217;t really matter if I typo&#8217;d something. Exchange and Exchagne &#8230; I know what I meant. But working under a more formal development process, &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[808,233],"class_list":["post-5497","post","type-post","status-publish","format-standard","hentry","category-coding","tag-branches","tag-git"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5497","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5497"}],"version-history":[{"count":1,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5497\/revisions"}],"predecessor-version":[{"id":5498,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5497\/revisions\/5498"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}