{"id":512,"date":"2024-11-05T00:37:45","date_gmt":"2024-11-04T16:37:45","guid":{"rendered":"http:\/\/www.wengdao.net\/?p=512"},"modified":"2024-11-05T00:43:00","modified_gmt":"2024-11-04T16:43:00","slug":"git-%e9%ab%98%e6%95%88%e5%b0%8f%e8%84%9a%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/jiandao.zliby.com\/?p=512","title":{"rendered":"Git \u9ad8\u6548\u5c0f\u811a\u672c"},"content":{"rendered":"<h3>\u5feb\u901f\u63d0\u4ea4\u6d41\u7a0b\u5c0f\u811a\u672c<\/h3>\n<p>\u53c2\u8003\u4e0a\u4e00\u7bc7\u628a\u811a\u6b65\u5f15\u5165 git \u547d\u4ee4\u884c\u6267\u884c<\/p>\n<p>Bash\u4f8b:<\/p>\n<pre><code class=\"prettyprint\" >#!\/bin\/sh\n\nif [ -z $2 ]; then\n    B=$(git name-rev --name-only HEAD)  \nelse\n    B=$2\nfi\n\nif [ $1 ]; then\n    echo &quot;git add . &quot;\n    git add .\n    echo &quot;git commit -m $1&quot;\n    git commit -m $1\nfi\n\nif [ $B ]; then\n    echo &quot;git pull origin $B&quot;\n    git pull origin $B \n    echo &quot;git push origin $B&quot;\n    git push origin $B \nfi<\/code><\/pre>\n<h3>\u5feb\u901f\u5efa\u5206\u652f\u5c0f\u811a\u672c<\/h3>\n<p>Bash\u4f8b:<\/p>\n<pre><code class=\"prettyprint\" >#!\/bin\/sh\n\nif [ -z $1 ]; then\n    echo $1\n    read -t 30 -p &quot;\u8bf7\u8f93\u5165\u6e90\u5206\u652f:&quot; B1\nelse\n    B1=$1\nfi\n\nif [ -z $2 ]; then\n    read -t 30 -p &quot;\u8bf7\u8f93\u5165\u751f\u6210\u5206\u652f:&quot; B2\nelse\n    B2=$2\nfi\n\nif [ $B1 -a $B2 ]; then\n    echo &quot;git checkout $B1&quot;\n    git checkout $B1\n    echo &quot;git pull origin $B1&quot;\n    git pull origin $B1\n    echo &quot;git checkout -b $B2&quot;\n    git checkout -b $B2\nfi\n<\/code><\/pre>\n<h3>\u83b7\u53d6\u5f53\u524d\u5206\u652f\u53f7 \u51e0\u79cd\u65b9\u5f0f<\/h3>\n<p><code class=\"prettyprint\" >git name-rev --name-only HEAD<\/code><\/p>\n<p><code class=\"prettyprint\" >git rev-parse --abbrev-ref HEAD<\/code><\/p>\n<p><code class=\"prettyprint\" >git symbolic-ref --short -q HEAD<\/code><\/p>\n<p><code class=\"prettyprint\" >git branch | awk  &#039;$1 == &quot;*&quot;{print $2}&#039;<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5feb\u901f\u63d0\u4ea4\u6d41\u7a0b\u5c0f\u811a\u672c \u53c2\u8003\u4e0a\u4e00\u7bc7\u628a\u811a\u6b65\u5f15\u5165 git \u547d\u4ee4\u884c\u6267\u884c Bash\u4f8b: #!\/bin\/sh if [ -z [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=\/wp\/v2\/posts\/512"}],"collection":[{"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=512"}],"version-history":[{"count":3,"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=\/wp\/v2\/posts\/512\/revisions"}],"predecessor-version":[{"id":515,"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=\/wp\/v2\/posts\/512\/revisions\/515"}],"wp:attachment":[{"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=512"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=512"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=512"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}