{"id":1514,"date":"2019-09-20T13:30:08","date_gmt":"2019-09-20T05:30:08","guid":{"rendered":"https:\/\/pjq.me\/?p=1514"},"modified":"2019-09-20T13:30:09","modified_gmt":"2019-09-20T05:30:09","slug":"auto-sync-branch-bash-script","status":"publish","type":"post","link":"https:\/\/pjq.me\/?p=1514","title":{"rendered":"Auto Sync Branch Bash Script"},"content":{"rendered":"\n<p>Don&#8217;t want to wast time to repeat the branch merge actions, like [A]>[B]>[C], so I create the bash script to run it automatically.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/github.com\/pjq\/auto_sync_branch\">https:\/\/github.com\/pjq\/auto_sync_branch<\/a><\/li><\/ul>\n\n\n\n<p>Script for auto sync\/merge the code from branch [A] to [B] with just one click<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_81 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/pjq.me\/?p=1514\/#Quick_Start\" >Quick Start<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/pjq.me\/?p=1514\/#How_to_update_the_configurations\" >How to update the configurations<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/pjq.me\/?p=1514\/#Update_Rules\" >Update Rules<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Quick_Start\"><\/span>Quick Start<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>chmod +x auto_sync_branch.sh\n.\/auto_sync_banch.sh -f config.txt.example<\/code><\/pre>\n\n\n\n<p><em>But you may have permission issue, as you are not the contributor of the this repo<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_update_the_configurations\"><\/span>How to update the configurations<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>cp config.txt.example config.txt<\/code><\/pre>\n\n\n\n<p>And update the configs to what you want<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DEVELOP_BRANCH=\"develop\"\nREMOTE_REPO=\"https:\/\/github.com\/pjq\/auto_sync_branch.git\"\nLOCAL_REPO=\"local\"\nWORKSPACE=\".\/auto_sync_branch_workspace\"\nRULE=\"master>develop|develop>pjq\/develop|pjq\/develop>user\/develop\"<\/code><\/pre>\n\n\n\n<p>Then run it<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>chmod +x auto_sync_branch.sh\n.\/auto_sync_branch.sh -f config.txt<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/auto_sync_branch.sh -f config.txt\nConfig file:config.txt\nread config...\nPrepare the workspace...\nCloning into 'local'...\nremote: Enumerating objects: 17, done.\nremote: Counting objects: 100% (17\/17), done.\nremote: Compressing objects: 100% (13\/13), done.\nremote: Total 17 (delta 4), reused 12 (delta 4), pack-reused 0\nUnpacking objects: 100% (17\/17), done.\nstart sync...\nSync rule master>develop\nStart Sync code from master to develop\nFrom https:\/\/github.com\/pjq\/auto_sync_branch\n * branch            master     -> FETCH_HEAD\nFrom https:\/\/github.com\/pjq\/auto_sync_branch\n * branch            develop    -> FETCH_HEAD\nAlready on 'develop'\nYour branch is up to date with 'origin\/develop'.\ngit checkout develop success!\nUpdating 3f0b2f9..13dae3f\nFast-forward\n auto_sync_branch.sh | 2 +-\n config.txt          | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\nMerge master > develop success!\nTotal 0 (delta 0), reused 0 (delta 0)\nTo https:\/\/github.com\/pjq\/auto_sync_branch.git\n   3f0b2f9..13dae3f  develop -> develop\nPush to remote success!\nSync master>develop success!\nSync rule develop>pjq\/develop\nStart Sync code from develop to pjq\/develop\nFrom https:\/\/github.com\/pjq\/auto_sync_branch\n * branch            develop    -> FETCH_HEAD\nFrom https:\/\/github.com\/pjq\/auto_sync_branch\n * branch            pjq\/develop -> FETCH_HEAD\nBranch 'pjq\/develop' set up to track remote branch 'pjq\/develop' from 'origin'.\nSwitched to a new branch 'pjq\/develop'\ngit checkout pjq\/develop success!\nUpdating 3f0b2f9..13dae3f\nFast-forward\n auto_sync_branch.sh | 2 +-\n config.txt          | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\nMerge develop > pjq\/develop success!\nTotal 0 (delta 0), reused 0 (delta 0)\nTo https:\/\/github.com\/pjq\/auto_sync_branch.git\n   3f0b2f9..13dae3f  pjq\/develop -> pjq\/develop\nPush to remote success!\nSync develop>pjq\/develop success!\nSync rule pjq\/develop>user\/develop\nStart Sync code from pjq\/develop to user\/develop\nFrom https:\/\/github.com\/pjq\/auto_sync_branch\n * branch            pjq\/develop -> FETCH_HEAD\nFrom https:\/\/github.com\/pjq\/auto_sync_branch\n * branch            user\/develop -> FETCH_HEAD\nBranch 'user\/develop' set up to track remote branch 'user\/develop' from 'origin'.\nSwitched to a new branch 'user\/develop'\ngit checkout user\/develop success!\nUpdating 3f0b2f9..13dae3f\nFast-forward\n auto_sync_branch.sh | 2 +-\n config.txt          | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\nMerge pjq\/develop > user\/develop success!\nTotal 0 (delta 0), reused 0 (delta 0)\nTo https:\/\/github.com\/pjq\/auto_sync_branch.git\n   3f0b2f9..13dae3f  user\/develop -> user\/develop\nPush to remote success!\nSync pjq\/develop>user\/develop success!<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Update_Rules\"><\/span>Update Rules<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The rule is simple, define the branch <code>from&gt;to<\/code>, and use &#8220;|&#8221; to split different rules<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>RULE=\"master>develop|develop>pjq\/develop|pjq\/develop>user\/develop\"<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Don&#8217;t want to wast time to repeat the branch merge actions, like [A]>[B]>[C], so I create the bash script to run it automatically. https:\/\/github.com\/pjq\/auto_sync_branch Script for auto sync\/merge the code from branch [A] to [B] with just one click Quick<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[169],"tags":[186,71],"class_list":["post-1514","post","type-post","status-publish","format-standard","hentry","category-tech","tag-bash","tag-github"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Auto Sync Branch Bash Script - Jianqing&#039;s Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/pjq.me\/?p=1514\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Auto Sync Branch Bash Script - Jianqing&#039;s Blog\" \/>\n<meta property=\"og:description\" content=\"Don&#8217;t want to wast time to repeat the branch merge actions, like [A]&gt;[B]&gt;[C], so I create the bash script to run it automatically. https:\/\/github.com\/pjq\/auto_sync_branch Script for auto sync\/merge the code from branch [A] to [B] with just one click Quick\" \/>\n<meta property=\"og:url\" content=\"https:\/\/pjq.me\/?p=1514\" \/>\n<meta property=\"og:site_name\" content=\"Jianqing&#039;s Blog\" \/>\n<meta property=\"article:published_time\" content=\"2019-09-20T05:30:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-09-20T05:30:09+00:00\" \/>\n<meta name=\"author\" content=\"pengjianqing\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"pengjianqing\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/pjq.me\/?p=1514#article\",\"isPartOf\":{\"@id\":\"https:\/\/pjq.me\/?p=1514\"},\"author\":{\"name\":\"pengjianqing\",\"@id\":\"https:\/\/pjq.me\/#\/schema\/person\/0eb1e72d1e69fbbd9b5c0bfd8e2aae60\"},\"headline\":\"Auto Sync Branch Bash Script\",\"datePublished\":\"2019-09-20T05:30:08+00:00\",\"dateModified\":\"2019-09-20T05:30:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/pjq.me\/?p=1514\"},\"wordCount\":104,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/pjq.me\/#\/schema\/person\/0eb1e72d1e69fbbd9b5c0bfd8e2aae60\"},\"keywords\":[\"Bash\",\"github\"],\"articleSection\":[\"Tech\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/pjq.me\/?p=1514#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/pjq.me\/?p=1514\",\"url\":\"https:\/\/pjq.me\/?p=1514\",\"name\":\"Auto Sync Branch Bash Script - Jianqing&#039;s Blog\",\"isPartOf\":{\"@id\":\"https:\/\/pjq.me\/#website\"},\"datePublished\":\"2019-09-20T05:30:08+00:00\",\"dateModified\":\"2019-09-20T05:30:09+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/pjq.me\/?p=1514#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/pjq.me\/?p=1514\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/pjq.me\/?p=1514#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/pjq.me\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Auto Sync Branch Bash Script\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/pjq.me\/#website\",\"url\":\"https:\/\/pjq.me\/\",\"name\":\"Jianqing&#039;s Blog\",\"description\":\"Thoughts and Future\",\"publisher\":{\"@id\":\"https:\/\/pjq.me\/#\/schema\/person\/0eb1e72d1e69fbbd9b5c0bfd8e2aae60\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/pjq.me\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/pjq.me\/#\/schema\/person\/0eb1e72d1e69fbbd9b5c0bfd8e2aae60\",\"name\":\"pengjianqing\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/pjq.me\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/pjq.me\/wp-content\/uploads\/2021\/12\/Screen-Shot-2021-12-02-at-6.10.58-PM.png\",\"contentUrl\":\"https:\/\/pjq.me\/wp-content\/uploads\/2021\/12\/Screen-Shot-2021-12-02-at-6.10.58-PM.png\",\"width\":460,\"height\":752,\"caption\":\"pengjianqing\"},\"logo\":{\"@id\":\"https:\/\/pjq.me\/#\/schema\/person\/image\/\"},\"url\":\"https:\/\/pjq.me\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Auto Sync Branch Bash Script - Jianqing&#039;s Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/pjq.me\/?p=1514","og_locale":"en_US","og_type":"article","og_title":"Auto Sync Branch Bash Script - Jianqing&#039;s Blog","og_description":"Don&#8217;t want to wast time to repeat the branch merge actions, like [A]>[B]>[C], so I create the bash script to run it automatically. https:\/\/github.com\/pjq\/auto_sync_branch Script for auto sync\/merge the code from branch [A] to [B] with just one click Quick","og_url":"https:\/\/pjq.me\/?p=1514","og_site_name":"Jianqing&#039;s Blog","article_published_time":"2019-09-20T05:30:08+00:00","article_modified_time":"2019-09-20T05:30:09+00:00","author":"pengjianqing","twitter_card":"summary_large_image","twitter_misc":{"Written by":"pengjianqing","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/pjq.me\/?p=1514#article","isPartOf":{"@id":"https:\/\/pjq.me\/?p=1514"},"author":{"name":"pengjianqing","@id":"https:\/\/pjq.me\/#\/schema\/person\/0eb1e72d1e69fbbd9b5c0bfd8e2aae60"},"headline":"Auto Sync Branch Bash Script","datePublished":"2019-09-20T05:30:08+00:00","dateModified":"2019-09-20T05:30:09+00:00","mainEntityOfPage":{"@id":"https:\/\/pjq.me\/?p=1514"},"wordCount":104,"commentCount":0,"publisher":{"@id":"https:\/\/pjq.me\/#\/schema\/person\/0eb1e72d1e69fbbd9b5c0bfd8e2aae60"},"keywords":["Bash","github"],"articleSection":["Tech"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/pjq.me\/?p=1514#respond"]}]},{"@type":"WebPage","@id":"https:\/\/pjq.me\/?p=1514","url":"https:\/\/pjq.me\/?p=1514","name":"Auto Sync Branch Bash Script - Jianqing&#039;s Blog","isPartOf":{"@id":"https:\/\/pjq.me\/#website"},"datePublished":"2019-09-20T05:30:08+00:00","dateModified":"2019-09-20T05:30:09+00:00","breadcrumb":{"@id":"https:\/\/pjq.me\/?p=1514#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/pjq.me\/?p=1514"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/pjq.me\/?p=1514#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/pjq.me\/"},{"@type":"ListItem","position":2,"name":"Auto Sync Branch Bash Script"}]},{"@type":"WebSite","@id":"https:\/\/pjq.me\/#website","url":"https:\/\/pjq.me\/","name":"Jianqing&#039;s Blog","description":"Thoughts and Future","publisher":{"@id":"https:\/\/pjq.me\/#\/schema\/person\/0eb1e72d1e69fbbd9b5c0bfd8e2aae60"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/pjq.me\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/pjq.me\/#\/schema\/person\/0eb1e72d1e69fbbd9b5c0bfd8e2aae60","name":"pengjianqing","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/pjq.me\/#\/schema\/person\/image\/","url":"https:\/\/pjq.me\/wp-content\/uploads\/2021\/12\/Screen-Shot-2021-12-02-at-6.10.58-PM.png","contentUrl":"https:\/\/pjq.me\/wp-content\/uploads\/2021\/12\/Screen-Shot-2021-12-02-at-6.10.58-PM.png","width":460,"height":752,"caption":"pengjianqing"},"logo":{"@id":"https:\/\/pjq.me\/#\/schema\/person\/image\/"},"url":"https:\/\/pjq.me\/?author=1"}]}},"views":15414,"_links":{"self":[{"href":"https:\/\/pjq.me\/index.php?rest_route=\/wp\/v2\/posts\/1514","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pjq.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pjq.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pjq.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pjq.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1514"}],"version-history":[{"count":2,"href":"https:\/\/pjq.me\/index.php?rest_route=\/wp\/v2\/posts\/1514\/revisions"}],"predecessor-version":[{"id":1516,"href":"https:\/\/pjq.me\/index.php?rest_route=\/wp\/v2\/posts\/1514\/revisions\/1516"}],"wp:attachment":[{"href":"https:\/\/pjq.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1514"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pjq.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1514"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pjq.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1514"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}