{"id":488,"date":"2019-07-10T10:31:12","date_gmt":"2019-07-10T17:31:12","guid":{"rendered":"http:\/\/35.243.195.209\/?page_id=488"},"modified":"2019-12-26T21:56:12","modified_gmt":"2019-12-27T05:56:12","slug":"git","status":"publish","type":"page","link":"https:\/\/nanzhou.cc\/index.php\/snippets\/git\/","title":{"rendered":"Git"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">1. Git Cleaning<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\"># clean local branches\ngit branch -d $(git branch --merged=master | grep -v master)\n# clean local remote branches\ngit fetch --prune<\/code><\/pre>\n\n\n\n<p>Reference: <a href=\"https:\/\/medium.com\/@FlorentDestrema\/a-simple-way-to-clean-up-your-git-project-branches-283b87478fbc\">here<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Rename Local Branches<\/h3>\n\n\n\n<p>Say you want to rename the branch old-name to new-name locally.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">git checkout old-name\ngit branch -m new-name\n# -m: move\/rename a branch and its reflog<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. Rename Local &amp; Remote Branches<\/h3>\n\n\n\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\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">git checkout old-name\ngit branch -m new-name\ngit push origin :old-name\n# &lt;+>&lt;source>:&lt;destination>  \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>1. Git Cleaning Reference: here 2. Rename Local Branches Say you want to rename the branch old-name to new-name locally. 3. Rename Local &amp; Remote Branches 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","protected":false},"author":1,"featured_media":0,"parent":452,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-488","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/pages\/488","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/types\/page"}],"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=488"}],"version-history":[{"count":5,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/pages\/488\/revisions"}],"predecessor-version":[{"id":710,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/pages\/488\/revisions\/710"}],"up":[{"embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/pages\/452"}],"wp:attachment":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/media?parent=488"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}