{"id":1069,"date":"2019-10-24T10:43:45","date_gmt":"2019-10-24T02:43:45","guid":{"rendered":"http:\/\/iqotom.com\/?p=1069"},"modified":"2019-12-19T09:37:43","modified_gmt":"2019-12-19T01:37:43","slug":"git%e5%91%bd%e4%bb%a4%e7%9a%84%e4%b8%80%e4%ba%9b%e6%80%bb%e7%bb%932","status":"publish","type":"post","link":"http:\/\/iqotom.com\/?p=1069","title":{"rendered":"Git\u547d\u4ee4\u7684\u4e00\u4e9b\u603b\u7ed32"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u524d\u8a00<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u8bb0\u5f55\u4e00\u4e9b\u5de5\u4f5c\u4e2d\u5e38\u7528\u7684git\u547d\u4ee4\uff0c\u4ee5\u4fbf\u7ecf\u540e\u67e5\u9605<\/h3>\n\n\n\n<p>\u300a<a href=\"http:\/\/iqotom.com\/?p=1062\">Git\u547d\u4ee4\u7684\u4e00\u4e9b\u603b\u7ed31<\/a>\u300b<br>\u300a<a href=\"http:\/\/iqotom.com\/?p=1069\">Git\u547d\u4ee4\u7684\u4e00\u4e9b\u603b\u7ed32<\/a>\u300b<\/p>\n\n\n\n<p><strong> \u5c06\u6240\u6709\u4ee3\u7801\u548c.repo\u76ee\u5f55\u90fd\u5220\u6389\u540e\u8981\u91cd\u65b0\u4e0b\u8f7d\u4ee3\u7801\u7684\u64cd\u4f5c <\/strong><\/p>\n\n\n\n<ol><li> \u91cd\u65b0\u751f\u6210.repo\u76ee\u5f55 repo init -u&nbsp;<a href=\"mailto:git@10.85.168.56:manifest\">git@ip:manifest<\/a> <\/li><li> \u540c\u6b65\u4ee3\u7801 repo sync <\/li><li> \u5728\u6240\u6709git\u5e93\u90fd\u65b0\u5f00\u4e00\u4e2amaster\u5206\u652f repo forall -c &#8220;git checkout -b master&#8221; <\/li><\/ol>\n\n\n\n<p> <strong>\u4e0b\u8f7d\u6700\u65b0\u4ee3\u7801 <\/strong><\/p>\n\n\n\n<ol><li> git pull origin master \u6216\u8005\u75282\u30013<\/li><li> git fetch origin master&nbsp;&nbsp; \u4e0b\u8f7d <\/li><li> git merge origin\/master&nbsp;&nbsp; \u5408\u5e76\u5230\u5f53\u524d\u5206\u652f\u4e0a <\/li><\/ol>\n\n\n\n<p> <strong>\u5207\u6362\u5206\u652f\u9047\u5230\u9519\u8bef <\/strong><br><code> Your local changes to the following files would be overwritten by checkout <\/code><\/p>\n\n\n\n<ol><li> git reset &#8211;hard&nbsp; \/\/\u7528\u4ee3\u7801\u5e93\u4e2d\u7684\u6587\u4ef6\u5b8c\u5168\u8986\u76d6\u672c\u5730\u5de5\u4f5c\u7248\u672c\uff0creset\u662f\u9488\u5bf9\u7248\u672c\u7684 <\/li><li> git pull <\/li><li> git checkout master <\/li><\/ol>\n\n\n\n<p><strong> \u7248\u672c\u56de\u9000\u548c\u5207\u6362\u5206\u652f <\/strong><\/p>\n\n\n\n<ol><li> git log&nbsp; \/\/\u67e5\u770b\u67d0\u4e2a\u5206\u652f\u7684commitid <\/li><li> git branch&nbsp; \/\/\u67e5\u770b\u76ee\u524d\u5904\u4e8e\u54ea\u4e2abranch <\/li><li> git branch branch_name commitid&nbsp; \/\/\u6839\u636ecommitid\u521b\u5efa\u5206\u652fbranch_name <\/li><li> git checkout branch_name&nbsp; \/\/\u5207\u6362\u5230\u65b0\u5efa\u7684\u5206\u652f <\/li><\/ol>\n\n\n\n<p><strong>\u653e\u5f03\u672c\u5730\u4fee\u6539\u7684\u4ee3\u7801<\/strong><\/p>\n\n\n\n<ol><li> repo forall -c &#8220;git reset &#8211;hard&#8221; <\/li><li> repo forall -c &#8220;git pull origin master&#8221; <\/li><li> repo forall -c &#8220;git checkout master&#8221; <\/li><\/ol>\n\n\n\n<p><strong>\u5207\u6362\u4ee3\u7801\u5206\u652f<\/strong><br> \u4f8b\u5982\u4ee3\u7801\u5e93\u4e0a\u9762\u65b0\u5f00\u4e86\u4e00\u4e2aHOSTING\u5206\u652f\uff0c\u5927\u5bb6\u53ef\u4ee5\u6839\u636e\u5982\u4e0b\u65b9\u6cd5\u66f4\u65b0\u5230HOSTING\u5206\u652f\uff1a <\/p>\n\n\n\n<p>1\u3001 \u5168\u65b0\u4e0b\u8f7d\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<p>repo init -u git@ip:manifest -m HOSTING.xml <br>repo sync<\/p>\n\n\n\n<p>2\u3001 \u5728\u539f\u6709\u4ee3\u7801\u57fa\u7840\u4e0a\u66f4\u65b0\u6210HOSTING\u5206\u652f\u7684\u65b9\u6cd5 \uff1a<\/p>\n\n\n\n<p>repo forall -c &#8220;git fetch &#8211;all &amp;&amp; git reset &#8211;hard origin\/HOSTING&#8221;<\/p>\n\n\n\n<p> \u5bf9HOSTING\u4ee3\u7801\u7684\u4fee\u6539\u63d0\u4ea4\u65f6\u8981\u6ce8\u610f\u63d0\u4ea4\u7684HOSTING\u5206\u652f\u4e0a\uff0c\u64cd\u4f5c\u65b9\u6cd5\uff1a <\/p>\n\n\n\n<p> git push origin HEAD:HOSTING <\/p>\n\n\n\n<p> \u4e00\u822c\u5728\u8fdb\u884cHOSTING\u4ee3\u7801\u4fee\u6539\u524d\u8bf7\u5148\u6267\u884c\u4e0b\u9762\u547d\u4ee4\uff0c\u4f7f\u5f53\u524d\u5206\u652f\u8ddf\u8e2a\u8fdc\u7a0bHOSTING\u5206\u652f\uff1a <br> <code>git reset --hard origin\/HOSTING<\/code>&nbsp;&nbsp; \/\/ \u6ce8\u610f\u89c2\u5bdf\u672c\u5730\u5206\u652f\u7684\u54c8\u5e0c\u6570\u548c\u54ea\u4e2a\u8fdc\u7a0b\u5206\u652f\u4e00\u6837\uff0c\u7136\u540e\u5c31\u53ef\u4ee5\u6b63\u5e38\u8fdb\u884c\u4fee\u6539\u63d0\u4ea4\u548cpull\u64cd\u4f5c\u4e86 <\/p>\n\n\n\n<p><strong> \u5bf9\u4e8e\u8981\u63d0\u4ea4\u5230\u4e3b\u5206\u652f\u548cHOSTING\u5206\u652f\u7684\u4ee3\u7801\u63d0\u4ea4\u5efa\u8bae\u6309\u5982\u4e0b\u64cd\u4f5c\uff1a <\/strong><\/p>\n\n\n\n<p>1\u3001 \u65b0\u5efa\u4e24\u4e2a\u672c\u5730\u5206\u652fmaster\u3001HOSTING <\/p>\n\n\n\n<p> \u65b0\u5efa\u5e76\u8ddf\u8e2a\u4e3b\u5206\u652f\uff1a <br> git checkout -b master remotes\/origin\/master <br> \u65b0\u5efaHOSTING\u8ddf\u8e2a\u5206\u652f\uff1a<br> git checkout -b HOSTING remotes\/origin\/HOSTING <\/p>\n\n\n\n<p>2\u3001 \u5728master\u4fee\u6539\u63d0\u4ea4\u540e\u8bb0\u4f4fcommit-id <\/p>\n\n\n\n<p>3\u3001 \u5207\u6362\u5230HOSTING\u5206\u652f\u540e\u4f7f\u7528cherry-pick\u547d\u4ee4 <br> git cherry-pick commit-id \uff08master\u5206\u652f\u4e0a\u7684\u63d0\u4ea4id\u53f7\uff09 <\/p>\n\n\n\n<p> \u8fd9\u6837\u5728master\u5206\u652f\u4e0a\u5bf9\u5e94\u63d0\u4ea4\u88ab\u62f7\u8d1d\u5230\u4e86\u5f53\u524d\u5206\u652f\uff0c\u7136\u540e\u5c31\u53ef\u4ee5\u8fdb\u884cpush\u64cd\u4f5c\u4e86 <\/p>\n\n\n\n<p><strong> \u514b\u9686\u4e00\u4e2a\u7279\u5b9a\u7684\u8fdc\u7a0b\u5206\u652f <\/strong><\/p>\n\n\n\n<ol><li> git init <\/li><li> git remote add -t BRANCH_NAME_HERE -f origin REMOTE_REPO_URL_PATH_HERE <\/li><li> git checkout BRANCH_NAME_HERE <\/li><\/ol>\n\n\n\n<p><strong> \u4ee5\u67d0\u4e2a\u8fdc\u7a0bbranch\u6700\u65b0\u7684\u4e00\u4e2asnapshot\u4e3a\u57fa\u7840\u521b\u5efa\u4e00\u4e2a\u65b0\u7684branch <\/strong><\/p>\n\n\n\n<p> git checkout -b newbranch origin\/remote_branch <\/p>\n\n\n\n<p> <strong>\u4ece\u8fdc\u7a0b\u62c9\u53d6dev\u5206\u652f\u5230\u672c\u5730\uff0c\u5e76\u5207\u6362\u5230dev\u5206\u652f <\/strong><\/p>\n\n\n\n<p> git checkout &#8211;track origin\/dev <\/p>\n\n\n\n<p><strong> \u4fee\u6539\u63d0\u4ea4\u4ee3\u7801\u6d41\u7a0b\uff1a <\/strong><\/p>\n\n\n\n<p>1\u3001 \u68c0\u67e5\u5f53\u524d\u5206\u652f\u4e0e\u8ddf\u8e2a\u5206\u652f <\/p>\n\n\n\n<p> git branch -a -v <\/p>\n\n\n\n<p>2\u3001 \u5982\u679c\u672c\u5730\u6ca1\u6709\u5efamaster\u5206\u652f\uff0c\u5219\u65b0\u5efa <\/p>\n\n\n\n<p> git checkout -b master remotes\/origin\/master <br> \u5982\u679c\u5df2\u6709master\u672c\u5730\u5206\u652f\u4f46\u662f\u6ca1\u6709\u8ddf\u8e2a\u8fdc\u7a0b\u7684master\u5206\u652f\uff0c\u5219\u8ddf\u8e2a <br> git reset &#8211;hard origin\/master <\/p>\n\n\n\n<p>3\u3001 \u66f4\u65b0\u6700\u65b0\u4ee3\u7801 <\/p>\n\n\n\n<p> git fetch &#8211;all <br> git merge origin\/master <\/p>\n\n\n\n<p>4\u3001 \u4fee\u6539\u4ee3\u7801\u5e76\u63d0\u4ea4 <\/p>\n\n\n\n<ol><li> \u4fee\u6539\u4ee3\u7801\u6587\u4ef6&#8230; <\/li><li> git status <\/li><li> git add file(\u6dfb\u52a0\u4fee\u6539\u7684\u6587\u4ef6)\/git add -u .(\u6682\u5b58\u5f53\u524d\u7684\u8def\u5f84)<\/li><li> git diff <\/li><li> git commit -m &#8220;Description&#8230; &#8221; <\/li><li> git push origin HEAD:master <\/li><\/ol>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u8bb0\u5f55\u4e00\u4e9b\u5de5\u4f5c\u4e2d\u5e38\u7528\u7684git\u547d\u4ee4\uff0c\u4ee5\u4fbf\u7ecf\u540e\u67e5\u9605 \u300aGit\u547d\u4ee4\u7684\u4e00\u4e9b\u603b\u7ed31\u300b\u300aGit\u547d\u4ee4\u7684\u4e00\u4e9b\u603b\u7ed32\u300b \u5c06\u6240\u2026 <span class=\"read-more\"><a href=\"http:\/\/iqotom.com\/?p=1069\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":1071,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[81],"tags":[89],"_links":{"self":[{"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/posts\/1069"}],"collection":[{"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/iqotom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1069"}],"version-history":[{"count":3,"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/posts\/1069\/revisions"}],"predecessor-version":[{"id":1266,"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/posts\/1069\/revisions\/1266"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/media\/1071"}],"wp:attachment":[{"href":"http:\/\/iqotom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1069"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/iqotom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1069"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/iqotom.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1069"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}