{"id":1001,"date":"2022-03-25T15:54:00","date_gmt":"2022-03-25T07:54:00","guid":{"rendered":"http:\/\/zhuxinyong.com\/?p=1001"},"modified":"2022-05-13T22:45:22","modified_gmt":"2022-05-13T14:45:22","slug":"git-zi-mo-kuai-wen-ti","status":"publish","type":"post","link":"https:\/\/zhuxinyong.com\/?p=1001","title":{"rendered":"Git \u5b50\u6a21\u5757\u95ee\u9898"},"content":{"rendered":"<h2><a id=\"%E5%88%86%E6%94%AF%E5%88%87%E6%8D%A2%E9%97%AE%E9%A2%98\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>\u5206\u652f\u5207\u6362\u95ee\u9898<\/h2>\n<p>\u6b63\u5e38\u60c5\u51b5\u4e0b\uff0c\u5207\u6362\u5206\u652f\u547d\u4ee4\uff1a<\/p>\n<pre><code class=\"language-plain_text\">git checkout branch-name\n<\/code><\/pre>\n<p>\u5f53\u4f60\u5728\u542b\u6709\u5b50\u4ed3\u5e93\u4e0b\u8fd0\u884c\u7684\u65f6\u5019\u4f1a\u9047\u5230\u5982\u4e0b\u95ee\u9898\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/zhuxinyong.com\/wp-content\/uploads\/2022\/04\/16493978943197.jpg\" alt=\"\" \/><\/p>\n<p>\u4e5f\u5c31\u662f\u4ece\u4e00\u4e2a\u6709\u5b50\u4ed3\u5e93\u7684\u5206\u652f\u5207\u6362\u5230\u4e00\u4e2a\u6ca1\u6709\u5b50\u4ed3\u5e93\u7684\u5206\u652f\uff0c\u5b50\u4ed3\u5e93\u76ee\u5f55\u88ab\u5e26\u8fc7\u53bb\u3002\u6ce8\u610f\uff1a\u867d\u7136\u76ee\u5f55\u88ab\u5e26\u8fc7\u53bb\u4e86\uff0c\u4f46\u662f\u4e0e submodule \u76f8\u5173\u7684\u914d\u7f6e\u5374\u6ca1\u6709\u5e26\u8fc7\u53bb\uff1a<\/p>\n<p>Git 2.13 \u4ee5\u524d\u7684\u7248\u672c\u4f1a\u6bd4\u8f83\u9ebb\u70e6\uff1a<\/p>\n<pre><code class=\"language-plain_text\">$ git --version\ngit version 2.12.2\n\n$ git checkout -b add-crypto\nSwitched to a new branch 'add-crypto'\n\n$ git submodule add https:\/\/github.com\/chaconinc\/CryptoLibrary\nCloning into 'CryptoLibrary'...\n...\n\n$ git commit -am 'adding crypto library'\n[add-crypto 4445836] adding crypto library\n 2 files changed, 4 insertions(+)\n create mode 160000 CryptoLibrary\n\n$ git checkout master\nwarning: unable to rmdir CryptoLibrary: Directory not empty\nSwitched to branch 'master'\nYour branch is up-to-date with 'origin\/master'.\n\n$ git status\nOn branch master\nYour branch is up-to-date with 'origin\/master'.\n\nUntracked files:\n  (use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)\n\n\tCryptoLibrary\/\n\nnothing added to commit but untracked files present (use &quot;git add&quot; to track)\n<\/code><\/pre>\n<p>\u79fb\u9664\u90a3\u4e2a\u76ee\u5f55\u5e76\u4e0d\u56f0\u96be\uff0c\u4f46\u662f\u6709\u4e00\u4e2a\u76ee\u5f55\u5728\u90a3\u513f\u4f1a\u8ba9\u4eba\u6709\u4e00\u70b9\u56f0\u60d1\u3002 \u5982\u679c\u4f60\u79fb\u9664\u5b83\u7136\u540e\u5207\u6362\u56de\u6709\u90a3\u4e2a\u5b50\u6a21\u5757\u7684\u5206\u652f\uff0c\u9700\u8981\u8fd0\u884c submodule update &#8211;init \u6765\u91cd\u65b0\u5efa\u7acb\u548c\u586b\u5145\u3002<\/p>\n<pre><code class=\"language-plain_text\">$ git clean -fdx\nRemoving CryptoLibrary\/\n\n$ git checkout add-crypto\nSwitched to branch 'add-crypto'\n\n$ ls CryptoLibrary\/\n\n$ git submodule update --init\nSubmodule path 'CryptoLibrary': checked out 'b8dda6aa182ea4464f3f3264b11e0268545172af'\n\n$ ls CryptoLibrary\/\nMakefile\tincludes\tscripts\t\tsrc\n<\/code><\/pre>\n<p>\u65b0\u7248\u7684 Git\uff08&gt;= 2.13\uff09\u901a\u8fc7\u4e3a git checkout \u547d\u4ee4\u6dfb\u52a0 &#8211;recurse-submodules \u9009\u9879\u7b80\u5316\u4e86\u6240\u6709\u8fd9\u4e9b\u6b65\u9aa4\uff0c \u5b83\u80fd\u4e3a\u4e86\u6211\u4eec\u8981\u5207\u6362\u5230\u7684\u5206\u652f\u8ba9\u5b50\u6a21\u5757\u5904\u4e8e\u7684\u6b63\u786e\u72b6\u6001\u3002<\/p>\n<pre><code class=\"language-plain_text\">$ git --version\ngit version 2.13.3\n\n$ git checkout -b add-crypto\nSwitched to a new branch 'add-crypto'\n\n$ git submodule add https:\/\/github.com\/chaconinc\/CryptoLibrary\nCloning into 'CryptoLibrary'...\n...\n\n$ git commit -am 'adding crypto library'\n[add-crypto 4445836] adding crypto library\n 2 files changed, 4 insertions(+)\n create mode 160000 CryptoLibrary\n\n$ git checkout --recurse-submodules master\nSwitched to branch 'master'\nYour branch is up-to-date with 'origin\/master'.\n\n$ git status\nOn branch master\nYour branch is up-to-date with 'origin\/master'.\n\nnothing to commit, working tree clean\n<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/zhuxinyong.com\/wp-content\/uploads\/2022\/04\/16496450095448.jpg\" alt=\"\" \/><\/p>\n<h3><a id=\"%E6%9B%B4%E6%96%B0%E9%97%AE%E9%A2%98\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>\u66f4\u65b0\u95ee\u9898<\/h3>\n<h4><a id=\"%E5%AD%90%E6%A8%A1%E5%9D%97%E6%9B%B4%E6%96%B0\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>\u5b50\u6a21\u5757\u66f4\u65b0<\/h4>\n<p>\u82e5\u5b50\u6a21\u5757\u66f4\u65b0\uff0c\u5219\u9700\u8981\u5230\u6240\u6709\u7684\u4f9d\u8d56\u5b50\u6a21\u5757\u7684\u4e3b\u4ed3\u5e93\u53bb\u66f4\u65b0\u4e00\u904d\uff0c\u7136\u540e\u5206\u522b\u63a8\u9001\u5230\u8fdc\u7aef\u4ed3\u5e93\u3002<\/p>\n<h4><a id=\"%E4%B8%BB%E4%BB%93%E5%BA%93%E5%86%85%E6%9B%B4%E6%96%B0\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>\u4e3b\u4ed3\u5e93\u5185\u66f4\u65b0<\/h4>\n<p>\u82e5\u4f60\u4e3b\u4ed3\u5e93\u66f4\u65b0\u4e86\u5b50\u6a21\u5757\u5e76\u63d0\u4ea4\u5230\u4e3b\u4ed3\u5e93\uff0c\u7136\u540e\u6784\u5efa\u7cfb\u7edf\u81ea\u52a8\u6784\u5efa\u5e76\u53d1\u5e03\u3002\u82e5\u540e\u9762\u6709\u5f00\u53d1\u4f19\u4f34\u6ca1\u6709\u66f4\u65b0\u5b50\u4ed3\u5e93\uff0c\u7136\u540e\u76f4\u63a5\u63d0\u4ea4\u4e86\u4ee3\u7801\uff0c\u5219\u4f1a\u628a\u4f60\u66f4\u65b0\u7684\u5b50\u4ed3\u5e93\u8fd8\u539f\u4e3a\u4e0a\u4e00\u4e2a\u7248\u672c\u3002<\/p>\n<p>\u597d\u4e60\u60ef\u907f\u514d\u7c7b\u4f3c\u95ee\u9898\uff1a\u4e3b\u4ed3\u5e93 <code>git pull<\/code> \u540e\uff0c\u63a5\u7740 <code>git status<\/code>\uff0c\u5b50\u6a21\u5757\u5982\u6709\u66f4\u65b0\u518d  <code>git submodule update<\/code>  \u6765\u540c\u6b65\u4e00\u4e0b\u4e3b\u4ed3\u5e93\u4e2d\u5b50\u6a21\u5757\u7684\u66f4\u65b0\u3002<\/p>\n<p>\u53c2\u8003\uff1a<\/p>\n<ol>\n<li><a href=\"https:\/\/git-scm.com\/book\/zh\/v2\/Git-%E5%B7%A5%E5%85%B7-%E5%AD%90%E6%A8%A1%E5%9D%97\" target=\"_blank\" rel=\"noopener\">https:\/\/git-scm.com\/book\/zh\/v2\/Git-%E5%B7%A5%E5%85%B7-%E5%AD%90%E6%A8%A1%E5%9D%97<\/a> \uff08\u591a\u770b\u51e0\u904d\uff09<\/li>\n<li><a href=\"https:\/\/blog.devtang.com\/2013\/05\/08\/git-submodule-issues\/\" target=\"_blank\" rel=\"noopener\">https:\/\/blog.devtang.com\/2013\/05\/08\/git-submodule-issues\/<\/a><\/li>\n<li><a href=\"https:\/\/juejin.cn\/post\/6844903920645455879\" target=\"_blank\" rel=\"noopener\">https:\/\/juejin.cn\/post\/6844903920645455879<\/a><\/li>\n<li><a href=\"https:\/\/liqiang.io\/post\/usage-and-tips-for-git-submodule\" target=\"_blank\" rel=\"noopener\">https:\/\/liqiang.io\/post\/usage-and-tips-for-git-submodule<\/a><\/li>\n<li><a href=\"https:\/\/www.jianshu.com\/p\/2393b6d53e42\" target=\"_blank\" rel=\"noopener\">https:\/\/www.jianshu.com\/p\/2393b6d53e42<\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u5206\u652f\u5207\u6362\u95ee\u9898 \u6b63\u5e38\u60c5\u51b5\u4e0b\uff0c\u5207\u6362\u5206\u652f\u547d\u4ee4\uff1a git checkout branch-name \u5f53\u4f60\u5728\u542b&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,27,3],"tags":[28,90],"class_list":["post-1001","post","type-post","status-publish","format-standard","hentry","category-all","category-tool","category-tech","tag-git","tag-submodule"],"_links":{"self":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts\/1001","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1001"}],"version-history":[{"count":4,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts\/1001\/revisions"}],"predecessor-version":[{"id":1153,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts\/1001\/revisions\/1153"}],"wp:attachment":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1001"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}