{"id":531986,"date":"2024-06-05T11:49:44","date_gmt":"2024-06-05T03:49:44","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/531986.html"},"modified":"2024-06-05T11:49:46","modified_gmt":"2024-06-05T03:49:46","slug":"%e5%9c%a8git%e4%b8%ad%e6%9c%89%e5%a4%9a%e4%b8%aa%e9%a1%b9%e7%9b%ae%e7%9b%ae%e5%bd%95%e5%a6%82%e4%bd%95%e7%ae%a1%e7%90%86","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/531986.html","title":{"rendered":"\u5728git\u4e2d\u6709\u591a\u4e2a\u9879\u76ee\u76ee\u5f55\u5982\u4f55\u7ba1\u7406"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24211516\/80c97197-5d94-42e7-b402-a5bb37cae02a.webp\" alt=\"\u5728git\u4e2d\u6709\u591a\u4e2a\u9879\u76ee\u76ee\u5f55\u5982\u4f55\u7ba1\u7406\" \/><\/p>\n<p><p>\u5728Git\u4e2d\u7ba1\u7406\u591a\u4e2a\u9879\u76ee\u76ee\u5f55\u4e3b\u8981\u4f9d\u8d56\u4e8e\u5408\u7406\u7684\u7ec4\u7ec7\u7ed3\u6784\u3001\u4f7f\u7528\u5b50\u6a21\u5757\uff08Submodules\uff09\u548c\u5206\u652f\u7ba1\u7406\u7b56\u7565\u3002<strong>\u5408\u7406\u7684\u7ec4\u7ec7\u7ed3\u6784\u8ba9\u9879\u76ee\u6613\u4e8e\u7406\u89e3\u548c\u7ef4\u62a4\u3001\u5b50\u6a21\u5757\u5141\u8bb8\u4f60\u5c06\u4e00\u4e2aGit\u4ed3\u5e93\u4f5c\u4e3a\u53e6\u4e00\u4e2aGit\u4ed3\u5e93\u7684\u5b50\u76ee\u5f55\u3001\u5206\u652f\u7ba1\u7406\u7b56\u7565\u5219\u4fdd\u8bc1\u4e86\u5404\u4e2a\u5f00\u53d1\u7ebf\u8def\u7684\u6e05\u6670\u72ec\u7acb<\/strong>\u3002\u7279\u522b\u662f\u4f7f\u7528\u5b50\u6a21\u5757\uff0c\u5b83\u5141\u8bb8\u9879\u76ee\u4f9d\u8d56\u7279\u5b9a\u7248\u672c\u7684\u5176\u4ed6\u9879\u76ee\uff0c\u8fd9\u5bf9\u4e8e\u5305\u542b\u4e86\u591a\u4e2a\u76f8\u4e92\u4f9d\u8d56\u7684\u5c0f\u9879\u76ee\u7684\u5927\u578b\u9879\u76ee\u5c24\u4e3a\u91cd\u8981\u3002<\/p>\n<\/p>\n<p><h3><strong>\u4e00\u3001\u5408\u7406\u7684\u7ec4\u7ec7\u7ed3\u6784<\/strong><\/h3>\n<\/p>\n<p><h4><strong>\u9879\u76ee\u5206\u7ec4<\/strong><\/h4>\n<\/p>\n<p><p>\u5c06\u76f8\u5173\u6027\u5f3a\u7684\u9879\u76ee\u653e\u5728\u540c\u4e00\u4e2a\u76ee\u5f55\u4e0b\uff0c\u4f8b\u5982\u6309\u529f\u80fd\u3001\u670d\u52a1\u6216\u56e2\u961f\u6765\u5206\u7ec4\u3002\u8fd9\u6837\u4e0d\u4ec5\u4fbf\u4e8e\u7ba1\u7406\uff0c\u4e5f\u4fbf\u4e8e\u65b0\u6210\u5458\u5feb\u901f\u719f\u6089\u9879\u76ee\u7ed3\u6784\u3002<\/p>\n<\/p>\n<p><h4><strong>\u547d\u540d\u89c4\u8303<\/strong><\/h4>\n<\/p>\n<p><p>\u4e3a\u9879\u76ee\u548c\u76ee\u5f55\u8bbe\u5b9a\u6e05\u6670\u3001\u4e00\u81f4\u7684\u547d\u540d\u89c4\u8303\u3002\u597d\u7684\u547d\u540d\u89c4\u8303\u80fd\u591f\u8ba9\u4eba\u4e00\u76ee\u4e86\u7136\u5730\u77e5\u9053\u9879\u76ee\u6216\u76ee\u5f55\u7684\u7528\u9014\uff0c\u4f8b\u5982\u4f7f\u7528\u9879\u76ee\u540d\u6216\u670d\u52a1\u540d\u4f5c\u4e3a\u76ee\u5f55\u540d\u3002<\/p>\n<\/p>\n<p><h3><strong>\u4e8c\u3001\u4f7f\u7528\u5b50\u6a21\u5757<\/strong><\/h3>\n<\/p>\n<p><h4><strong>\u5b50\u6a21\u5757\u7684\u6dfb\u52a0<\/strong><\/h4>\n<\/p>\n<p><p>\u5f53\u9700\u8981\u5728\u9879\u76ee\u4e2d\u5f15\u7528\u53e6\u4e00\u4e2a\u9879\u76ee\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7<code>git submodule add &lt;repository&gt; &lt;path&gt;<\/code>\u547d\u4ee4\u6765\u6dfb\u52a0\u5b50\u6a21\u5757\u3002\u8fd9\u6837\u505a\u7684\u597d\u5904\u662f\u53ef\u4ee5\u6307\u5b9a\u9879\u76ee\u4f9d\u8d56\u7684\u5177\u4f53\u7248\u672c\uff0c\u907f\u514d\u4e86\u7248\u672c\u4e0d\u4e00\u81f4\u5bfc\u81f4\u7684\u95ee\u9898\u3002<\/p>\n<\/p>\n<p><h4><strong>\u5b50\u6a21\u5757\u7684\u66f4\u65b0<\/strong><\/h4>\n<\/p>\n<p><p>\u5b50\u6a21\u5757\u4e0d\u4f1a\u968f\u7740\u4e3b\u4ed3\u5e93\u81ea\u52a8\u66f4\u65b0\uff0c\u9700\u8981\u624b\u52a8\u66f4\u65b0\u3002\u901a\u8fc7<code>git submodule update --remote<\/code>\u547d\u4ee4\uff0c\u53ef\u4ee5\u5c06\u5b50\u6a21\u5757\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\u6216\u6307\u5b9a\u7248\u672c\u3002\u8fd9\u5bf9\u4e8e\u7ba1\u7406\u4f9d\u8d56\u5176\u4ed6\u9879\u76ee\u7684\u590d\u6742\u9879\u76ee\u5c24\u4e3a\u91cd\u8981\u3002<\/p>\n<\/p>\n<p><h3><strong>\u4e09\u3001\u5206\u652f\u7ba1\u7406\u7b56\u7565<\/strong><\/h3>\n<\/p>\n<p><h4><strong>\u529f\u80fd\u5206\u652f<\/strong><\/h4>\n<\/p>\n<p><p>\u5bf9\u4e8e\u6bcf\u4e00\u4e2a\u65b0\u529f\u80fd\u6216\u4fee\u590d\uff0c\u90fd\u5e94\u8be5\u5728\u5355\u72ec\u7684\u5206\u652f\u4e0a\u8fdb\u884c\u5f00\u53d1\uff0c\u8fd9\u6837\u505a\u53ef\u4ee5\u4fdd\u8bc1\u4e3b\u5206\u652f\u7684\u7a33\u5b9a\u6027\u3002\u5b8c\u6210\u540e\uff0c\u518d\u901a\u8fc7\u5408\u5e76\u8bf7\u6c42\uff08Merge Request\uff09\u6216\u62c9\u53d6\u8bf7\u6c42\uff08Pull Request\uff09\u5c06\u6539\u52a8\u5408\u5e76\u56de\u4e3b\u5206\u652f\u3002<\/p>\n<\/p>\n<p><h4><strong>\u7248\u672c\u5206\u652f<\/strong><\/h4>\n<\/p>\n<p><p>\u5bf9\u4e8e\u9700\u8981\u957f\u671f\u652f\u6301\u7684\u9879\u76ee\uff0c\u53ef\u4ee5\u4e3a\u6bcf\u4e2a\u53d1\u5e03\u7248\u672c\u521b\u5efa\u4e00\u4e2a\u5206\u652f\u3002\u8fd9\u6837\u505a\u4fbf\u4e8e\u5bf9\u7279\u5b9a\u7248\u672c\u8fdb\u884c\u8865\u4e01\u66f4\u65b0\uff0c\u540c\u65f6\u4e5f\u80fd\u591f\u7ee7\u7eed\u5728\u4e3b\u5206\u652f\u4e0a\u8fdb\u884c\u4e0b\u4e00\u7248\u672c\u7684\u5f00\u53d1\u3002<\/p>\n<\/p>\n<p><h3><strong>\u56db\u3001\u5de5\u4f5c\u6d41\u7ba1\u7406<\/strong><\/h3>\n<\/p>\n<p><h4><strong>\u9009\u62e9\u5408\u9002\u7684\u5de5\u4f5c\u6d41<\/strong><\/h4>\n<\/p>\n<p><p>\u6839\u636e\u56e2\u961f\u7684\u89c4\u6a21\u548c\u9879\u76ee\u7684\u590d\u6742\u5ea6\uff0c\u9009\u62e9\u5408\u9002\u7684\u5de5\u4f5c\u6d41\uff0c\u5982Gitflow\u3001GitHub Flow\u6216GitLab Flow\u3002\u6bcf\u79cd\u5de5\u4f5c\u6d41\u90fd\u6709\u5176\u7279\u70b9\u548c\u9002\u7528\u573a\u666f\uff0c\u9009\u62e9\u5408\u9002\u7684\u5de5\u4f5c\u6d41\u80fd\u591f\u6709\u6548\u63d0\u5347\u56e2\u961f\u7684\u534f\u4f5c\u6548\u7387\u3002<\/p>\n<\/p>\n<p><h4><strong>\u5b9a\u671f<a href=\"https:\/\/docs.pingcode.com\/code-review\" target=\"_blank\">\u4ee3\u7801\u5ba1\u67e5<\/a><\/strong><\/h4>\n<\/p>\n<p><p>\u65e0\u8bba\u91c7\u7528\u54ea\u79cd\u5de5\u4f5c\u6d41\uff0c\u5b9a\u671f\u7684\u4ee3\u7801\u5ba1\u67e5\u90fd\u662f\u5fc5\u4e0d\u53ef\u5c11\u7684\u3002\u4ee3\u7801\u5ba1\u67e5\u4e0d\u4ec5\u80fd\u591f\u63d0\u9ad8\u4ee3\u7801\u8d28\u91cf\uff0c\u8fd8\u80fd\u591f\u4fc3\u8fdb\u56e2\u961f\u6210\u5458\u4e4b\u95f4\u7684\u77e5\u8bc6\u5206\u4eab\u3002<\/p>\n<\/p>\n<p><h3><strong>\u4e94\u3001\u81ea\u52a8\u5316\u548c\u811a\u672c<\/strong><\/h3>\n<\/p>\n<p><h4><strong>\u81ea\u52a8\u5316\u6784\u5efa\u548c\u90e8\u7f72<\/strong><\/h4>\n<\/p>\n<p><p>\u901a\u8fc7\u6301\u7eed\u96c6\u6210\uff08CI\uff09\u548c\u6301\u7eed\u90e8\u7f72\uff08CD\uff09\u5de5\u5177\u81ea\u52a8\u5316\u6784\u5efa\u548c\u90e8\u7f72\u8fc7\u7a0b\uff0c\u51cf\u5c11\u4eba\u4e3a\u9519\u8bef\uff0c\u63d0\u9ad8\u6548\u7387\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528Jenkins\u3001GitLab <a href=\"https:\/\/docs.pingcode.com\/blog\/devops\/52691.html\" target=\"_blank\">CI\/CD<\/a>\u6216GitHub Actions\u6765\u5b9e\u73b0\u81ea\u52a8\u5316\u6d41\u7a0b\u3002<\/p>\n<\/p>\n<p><h4><strong>\u7f16\u5199\u811a\u672c\u7b80\u5316\u65e5\u5e38\u64cd\u4f5c<\/strong><\/h4>\n<\/p>\n<p><p>\u5bf9\u4e8e\u91cd\u590d\u6027\u9ad8\u7684\u64cd\u4f5c\uff0c\u5982\u521b\u5efa\u5206\u652f\u3001\u66f4\u65b0\u5b50\u6a21\u5757\u7b49\uff0c\u53ef\u4ee5\u7f16\u5199\u811a\u672c\u6765\u7b80\u5316\u8fd9\u4e9b\u64cd\u4f5c\u3002\u8fd9\u6837\u4e0d\u4ec5\u53ef\u4ee5\u63d0\u9ad8\u5de5\u4f5c\u6548\u7387\uff0c\u8fd8\u53ef\u4ee5\u51cf\u5c11\u56e0\u64cd\u4f5c\u5931\u8bef\u5bfc\u81f4\u7684\u95ee\u9898\u3002<\/p>\n<\/p>\n<p><p><strong>\u603b\u7ed3<\/strong>\uff0c\u5728Git\u4e2d\u7ba1\u7406\u591a\u4e2a\u9879\u76ee\u76ee\u5f55\u9700\u8981\u7efc\u5408\u8fd0\u7528\u5408\u7406\u7684\u7ec4\u7ec7\u7ed3\u6784\u3001\u5b50\u6a21\u5757\u3001\u5206\u652f\u7ba1\u7406\u7b56\u7565\u3001\u5408\u9002\u7684\u5de5\u4f5c\u6d41\u3001\u4ee5\u53ca\u81ea\u52a8\u5316\u548c\u811a\u672c\u7b49\u6280\u5de7\u3002\u901a\u8fc7\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u63d0\u5347<a href=\"https:\/\/docs.pingcode.com\/blog\/project-management\/23316.html\" target=\"_blank\">\u9879\u76ee\u7ba1\u7406<\/a>\u7684\u6548\u7387\u548c\u8d28\u91cf\uff0c\u786e\u4fdd\u9879\u76ee\u7684\u7a33\u5b9a\u53d1\u5c55\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>1. \u5982\u4f55\u5728Git\u4e2d\u7ba1\u7406\u591a\u4e2a\u9879\u76ee\u76ee\u5f55\uff1f<\/strong><\/p>\n<ul>\n<li>\u95ee\u9898\uff1a\u6211\u6709\u591a\u4e2a\u9879\u76ee\u76ee\u5f55\uff0c\u60f3\u8981\u4f7f\u7528Git\u6765\u8fdb\u884c\u7248\u672c\u63a7\u5236\uff0c\u5e94\u8be5\u5982\u4f55\u7ba1\u7406\u8fd9\u4e9b\u76ee\u5f55\uff1f<\/li>\n<li>\u56de\u7b54\uff1a\u60a8\u53ef\u4ee5\u4f7f\u7528Git\u7684\u4ed3\u5e93\u7ba1\u7406\u529f\u80fd\u6765\u7ba1\u7406\u591a\u4e2a\u9879\u76ee\u76ee\u5f55\u3002\u6bcf\u4e2a\u9879\u76ee\u76ee\u5f55\u53ef\u4ee5\u4f5c\u4e3a\u4e00\u4e2a\u72ec\u7acb\u7684Git\u4ed3\u5e93\uff0c\u60a8\u53ef\u4ee5\u5728\u6bcf\u4e2a\u76ee\u5f55\u4e0b\u521d\u59cb\u5316\u4e00\u4e2a\u65b0\u7684\u4ed3\u5e93\uff0c\u5e76\u5206\u522b\u8fdb\u884c\u7248\u672c\u63a7\u5236\u3002\u8fd9\u6837\u53ef\u4ee5\u4fdd\u6301\u6bcf\u4e2a\u9879\u76ee\u7684\u72ec\u7acb\u6027\uff0c\u65b9\u4fbf\u7ba1\u7406\u548c\u7ef4\u62a4\u3002<\/li>\n<\/ul>\n<p><strong>2. \u5982\u4f55\u5728Git\u4e2d\u5207\u6362\u4e0d\u540c\u7684\u9879\u76ee\u76ee\u5f55\uff1f<\/strong><\/p>\n<ul>\n<li>\u95ee\u9898\uff1a\u6211\u5df2\u7ecf\u5728\u4e00\u4e2a\u9879\u76ee\u76ee\u5f55\u4e2d\u521d\u59cb\u5316\u4e86\u4e00\u4e2aGit\u4ed3\u5e93\uff0c\u73b0\u5728\u60f3\u8981\u5207\u6362\u5230\u53e6\u4e00\u4e2a\u9879\u76ee\u76ee\u5f55\u8fdb\u884c\u7248\u672c\u63a7\u5236\uff0c\u5e94\u8be5\u5982\u4f55\u64cd\u4f5c\uff1f<\/li>\n<li>\u56de\u7b54\uff1a\u5728\u5207\u6362\u5230\u53e6\u4e00\u4e2a\u9879\u76ee\u76ee\u5f55\u4e4b\u524d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528<code>git status<\/code>\u547d\u4ee4\u67e5\u770b\u5f53\u524d\u9879\u76ee\u76ee\u5f55\u4e0b\u662f\u5426\u6709\u672a\u63d0\u4ea4\u7684\u66f4\u6539\u3002\u5982\u679c\u6709\u672a\u63d0\u4ea4\u7684\u66f4\u6539\uff0c\u53ef\u4ee5\u4f7f\u7528<code>git stash<\/code>\u547d\u4ee4\u5c06\u66f4\u6539\u6682\u5b58\u8d77\u6765\uff0c\u7136\u540e\u518d\u5207\u6362\u5230\u5176\u4ed6\u9879\u76ee\u76ee\u5f55\u3002\u5207\u6362\u5230\u5176\u4ed6\u9879\u76ee\u76ee\u5f55\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528<code>git init<\/code>\u547d\u4ee4\u521d\u59cb\u5316\u4e00\u4e2a\u65b0\u7684Git\u4ed3\u5e93\uff0c\u5e76\u8fdb\u884c\u7248\u672c\u63a7\u5236\u3002<\/li>\n<\/ul>\n<p><strong>3. \u5982\u4f55\u5728Git\u4e2d\u540c\u65f6\u7ba1\u7406\u591a\u4e2a\u9879\u76ee\u76ee\u5f55\u7684\u4ee3\u7801\uff1f<\/strong><\/p>\n<ul>\n<li>\u95ee\u9898\uff1a\u6211\u6709\u591a\u4e2a\u9879\u76ee\u76ee\u5f55\uff0c\u5e0c\u671b\u80fd\u591f\u5728Git\u4e2d\u540c\u65f6\u7ba1\u7406\u8fd9\u4e9b\u76ee\u5f55\u7684\u4ee3\u7801\uff0c\u65b9\u4fbf\u7248\u672c\u63a7\u5236\u548c\u534f\u4f5c\u5f00\u53d1\uff0c\u5e94\u8be5\u5982\u4f55\u64cd\u4f5c\uff1f<\/li>\n<li>\u56de\u7b54\uff1a\u60a8\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2aGit\u8d85\u7ea7\u4ed3\u5e93\uff0c\u5c06\u591a\u4e2a\u9879\u76ee\u76ee\u5f55\u4f5c\u4e3a\u8be5\u8d85\u7ea7\u4ed3\u5e93\u7684\u5b50\u4ed3\u5e93\u8fdb\u884c\u7ba1\u7406\u3002\u8fd9\u6837\u53ef\u4ee5\u65b9\u4fbf\u5730\u5728\u4e00\u4e2a\u4ed3\u5e93\u4e2d\u7ba1\u7406\u591a\u4e2a\u9879\u76ee\u7684\u4ee3\u7801\uff0c\u540c\u65f6\u53ef\u4ee5\u4f7f\u7528Git\u7684\u5206\u652f\u548c\u5408\u5e76\u529f\u80fd\u8fdb\u884c\u534f\u4f5c\u5f00\u53d1\u3002\u60a8\u53ef\u4ee5\u5728\u8d85\u7ea7\u4ed3\u5e93\u7684\u6839\u76ee\u5f55\u4e0b\u4f7f\u7528<code>git submodule add<\/code>\u547d\u4ee4\u6dfb\u52a0\u5b50\u4ed3\u5e93\uff0c\u5e76\u5728\u5b50\u4ed3\u5e93\u4e2d\u8fdb\u884c\u72ec\u7acb\u7684\u7248\u672c\u63a7\u5236\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"\u5728Git\u4e2d\u7ba1\u7406\u591a\u4e2a\u9879\u76ee\u76ee\u5f55\u4e3b\u8981\u4f9d\u8d56\u4e8e\u5408\u7406\u7684\u7ec4\u7ec7\u7ed3\u6784\u3001\u4f7f\u7528\u5b50\u6a21\u5757\uff08Submodules\uff09\u548c\u5206\u652f\u7ba1\u7406\u7b56\u7565\u3002\u5408\u7406\u7684\u7ec4 [&hellip;]","protected":false},"author":3,"featured_media":531988,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/531986"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=531986"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/531986\/revisions"}],"predecessor-version":[{"id":531989,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/531986\/revisions\/531989"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/531988"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=531986"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=531986"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=531986"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}