{"id":336,"date":"2019-03-02T11:29:24","date_gmt":"2019-03-02T19:29:24","guid":{"rendered":"http:\/\/35.243.195.209\/?p=336"},"modified":"2020-06-02T22:58:18","modified_gmt":"2020-06-03T05:58:18","slug":"git-snippets","status":"publish","type":"post","link":"https:\/\/nanzhou.cc\/index.php\/2019\/03\/02\/git-snippets\/","title":{"rendered":"Git Snippets"},"content":{"rendered":"<h2>Summary<\/h2>\n<p>In this post, I will introduce some useful snippets related to Git. I will update this post from time to time.<\/p>\n<h2>Details<\/h2>\n<h3>Rename Local Branches<\/h3>\n<p>Say you want to rename the branch old-name to new-name locally.<\/p>\n<pre><code class=\"language-bash\">git checkout old-name\ngit branch -m new-name\n# -m: move\/rename a branch and its reflog<\/code><\/pre>\n<h3>Rename Local &amp; Remote Branches<\/h3>\n<p>Say you want to rename the branch old-name to new-name locally, then push it to remote and delete the original remote brach.<\/p>\n<pre><code class=\"language-bash\">git checkout old-name\ngit branch -m new-name\ngit push origin :old-name\n# &amp;lt;+&amp;gt;&amp;lt;source&amp;gt;:&amp;lt;destination&amp;gt;  \n# git push origin :old-name means make origin old-name empty\ngit push --set-upstream origin new-name<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Summary In this post, I will introduce some useful snippets related to Git. I will update this post from time to time. Details Rename Local Branches Say you want to rename the branch old-name to new-name locally. git checkout old-name git branch -m new-name # -m: move\/rename a branch and its reflog Rename Local &amp;&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25,44],"tags":[],"class_list":["post-336","post","type-post","status-publish","format-standard","hentry","category-software-engineering","category-version-control"],"_links":{"self":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts\/336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/comments?post=336"}],"version-history":[{"count":5,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts\/336\/revisions"}],"predecessor-version":[{"id":1273,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts\/336\/revisions\/1273"}],"wp:attachment":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/media?parent=336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/categories?post=336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/tags?post=336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}