{"id":20302,"date":"2024-11-19T16:40:29","date_gmt":"2024-11-19T08:40:29","guid":{"rendered":"https:\/\/fwq.ai\/blog\/20302\/"},"modified":"2024-11-19T16:40:29","modified_gmt":"2024-11-19T08:40:29","slug":"git%e5%a6%82%e4%bd%95%e5%bb%ba%e6%9c%ac%e5%9c%b0%e5%88%86%e6%94%af","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/20302\/","title":{"rendered":"git\u5982\u4f55\u5efa\u672c\u5730\u5206\u652f"},"content":{"rendered":"<p>git\u662f\u4e00\u6b3e\u975e\u5e38\u6d41\u884c\u7684\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u4f7f\u7528git\u8fdb\u884c\u7248\u672c\u63a7\u5236\u53ef\u4ee5\u8ba9\u6211\u4eec\u66f4\u597d\u5730\u7ba1\u7406\u4ee3\u7801\u3002\u800c\u5728git\u4e2d\uff0c\u5206\u652f\u662f\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u6982\u5ff5\uff0c\u53ef\u4ee5\u5b9e\u73b0\u5bf9\u4ee3\u7801\u7684\u591a\u7248\u672c\u7ba1\u7406\u548c\u5f00\u53d1\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u5728git\u4e2d\u5efa\u7acb\u672c\u5730\u5206\u652f\u3002<\/p>\n<p>\u4e00\u3001\u4ec0\u4e48\u662f\u5206\u652f\uff1f<\/p>\n<p>\u5206\u652f\u6307\u7684\u662fGit\u4ed3\u5e93\u4e2d\u7684\u4e00\u6761\u547d\u540d\u7684\u3001\u53ef\u53d8\u7684\u63d0\u4ea4\u94fe\u3002\u5728Git\u4ed3\u5e93\u4e2d\uff0c\u9ed8\u8ba4\u5b58\u5728\u4e00\u4e2a\u540d\u4e3a\u201cmaster\u201d\u7684\u5206\u652f\u3002\u6211\u4eec\u53ef\u4ee5\u5728\u201cmaster\u201d\u5206\u652f\u4e0a\u8fdb\u884c\u63d0\u4ea4\uff0c\u4e5f\u53ef\u4ee5\u5728\u201cmaster\u201d\u5206\u652f\u4e4b\u5916\u5efa\u7acb\u65b0\u7684\u5206\u652f\u8fdb\u884c\u5f00\u53d1\u3002<\/p>\n<p>\u4f7f\u7528\u5206\u652f\u7684\u597d\u5904\u662f\u53ef\u4ee5\u8ba9\u6211\u4eec\u5728\u4ee3\u7801\u5f00\u53d1\u548c\u4fee\u6539\u8fc7\u7a0b\u4e2d\uff0c\u9694\u79bb\u5f53\u524d\u7684\u5f00\u53d1\u4efb\u52a1\uff0c\u4e0d\u4f1a\u5f71\u54cd\u5230\u539f\u6709\u7684\u4ee3\u7801\u3002\u540c\u65f6\uff0c\u5728\u4e0d\u540c\u7684\u5206\u652f\u4e0a\u5f00\u53d1\uff0c\u53ef\u4ee5\u4fdd\u8bc1\u5404\u79cd\u529f\u80fd\u5f00\u53d1\u4e0d\u4f1a\u4e92\u76f8\u5e72\u6270\u3002\u5f53\u9700\u8981\u5c06\u5404\u4e2a\u5206\u652f\u7684\u4ee3\u7801\u5408\u5e76\u65f6\uff0cGit\u4e5f\u63d0\u4f9b\u4e86\u5408\u5e76\u5206\u652f\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u8fdb\u884c\u4ee3\u7801\u5408\u5e76\u3002<\/p>\n<p>\u4e8c\u3001\u5efa\u7acb\u672c\u5730\u5206\u652f<\/p>\n<p>\u5728Git\u4e2d\uff0c\u5efa\u7acb\u672c\u5730\u5206\u652f\u975e\u5e38\u7b80\u5355\u3002\u53ea\u9700\u8981\u5728\u5f53\u524d\u4ed3\u5e93\u4e2d\uff0c\u4f7f\u7528\u201cgit branch\u201d\u547d\u4ee4\u52a0\u4e0a\u5206\u652f\u540d\u79f0\u5373\u53ef\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>$ git branch develop<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fd9\u6837\u5c31\u5efa\u7acb\u4e86\u4e00\u4e2a\u540d\u4e3a\u201cdevelop\u201d\u7684\u65b0\u5206\u652f\u3002\u6b64\u65f6\uff0c\u6211\u4eec\u8fd8\u6ca1\u6709\u5207\u6362\u5230\u8be5\u5206\u652f\u4e0a\uff0c\u4f7f\u7528\u201cgit branch\u201d\u547d\u4ee4\u53ef\u4ee5\u67e5\u770b\u5f53\u524d\u6240\u6709\u5206\u652f\u53ca\u5176\u72b6\u6001\u3002<\/p>\n<pre>$ git branch\n\n* master\n  develop<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u67e5\u770b\u5230\u201c*\u201d\u53f7\u6240\u5728\u7684\u5206\u652f\u5c31\u662f\u5f53\u524d\u6240\u5728\u7684\u5206\u652f\uff0c\u201cmaster\u201d\u662f\u9ed8\u8ba4\u521b\u5efa\u7684\u4e3b\u5206\u652f\uff0c\u800c\u201cdevelop\u201d\u662f\u65b0\u5efa\u7684\u5206\u652f\u3002<\/p>\n<p>\u5982\u679c\u9700\u8981\u5207\u6362\u5230\u201cdevelop\u201d\u5206\u652f\uff0c\u53ef\u4ee5\u4f7f\u7528\u201cgit checkout\u201d\u547d\u4ee4\u8fdb\u884c\u5207\u6362\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>$ git checkout develop<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5207\u6362\u5230\u201cdevelop\u201d\u5206\u652f\u540e\uff0c\u53ef\u4ee5\u5728\u8fd9\u4e2a\u5206\u652f\u4e0a\u8fdb\u884c\u4ee3\u7801\u4fee\u6539\u548c\u63d0\u4ea4\u3002\u5982\u679c\u9700\u8981\u67e5\u770b\u5f53\u524d\u6240\u5904\u7684\u5206\u652f\uff0c\u53ef\u4ee5\u4f7f\u7528\u201cgit status\u201d\u547d\u4ee4\u67e5\u770b\u72b6\u6001\u4fe1\u606f\u3002<\/p>\n<pre>$ git status\n\nOn branch develop\nnothing to commit, working tree clean<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4e09\u3001\u521b\u5efa\u5206\u652f\u65f6\u57fa\u4e8e\u67d0\u4e2acommit\u70b9<\/p>\n<p>\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d\uff0c\u6211\u4eec\u4e0d\u4ec5\u53ef\u4ee5\u5728\u5f53\u524d\u5206\u652f\u4e0a\u8fdb\u884c\u5206\u652f\u7684\u5efa\u7acb\uff0c\u8fd8\u53ef\u4ee5\u5728\u67d0\u4e2a\u63d0\u4ea4\u70b9\u4e0a\u8fdb\u884c\u5206\u652f\u7684\u5efa\u7acb\u3002\u8fd9\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>$ git branch new_branch_name commit_SHA<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5176\u4e2d\uff0c\u201cnew_branch_name\u201d\u662f\u65b0\u5efa\u5206\u652f\u7684\u540d\u79f0\uff0c\u201ccommit_SHA\u201d\u662f\u6307\u5b9a\u7684\u67d0\u4e2a\u63d0\u4ea4\u70b9\u7684commit\u53f7\u3002<\/p>\n<p>\u56db\u3001\u5408\u5e76\u5206\u652f<\/p>\n<p>\u5f53\u6211\u4eec\u5728\u4e0d\u540c\u7684\u5206\u652f\u4e0a\u8fdb\u884c\u5f00\u53d1\u5b8c\u6210\u540e\uff0c\u5c31\u53ef\u4ee5\u5c06\u4e24\u4e2a\u5206\u652f\u5408\u5e76\u3002Git\u63d0\u4f9b\u4e86\u4e24\u79cd\u5408\u5e76\u65b9\u5f0f\uff1amerge\u548crebase\u3002\u8fd9\u91cc\u6211\u4eec\u4ee5merge\u4e3a\u4f8b\u8fdb\u884c\u8bb2\u89e3\u3002<\/p>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u9700\u8981\u5207\u6362\u5230\u9700\u8981\u63a5\u53d7\u53d8\u66f4\u7684\u5206\u652f\u4e0a\uff0c\u4f7f\u7528\u201cgit merge\u201d\u547d\u4ee4\u5408\u5e76\u5206\u652f\u3002\u4f8b\u5982\uff0c\u5982\u679c\u9700\u8981\u5c06\u201cdevelop\u201d\u5206\u652f\u5408\u5e76\u5230\u201cmaster\u201d\u5206\u652f\u4e0a\uff1a<\/p>\n<pre>$ git checkout master\n$ git merge develop<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fd9\u6837\u5c31\u5b8c\u6210\u4e86\u5206\u652f\u7684\u5408\u5e76\u3002<\/p>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5982\u679c\u5728\u5408\u5e76\u5206\u652f\u65f6\u51fa\u73b0\u51b2\u7a81\uff0c\u9700\u8981\u624b\u52a8\u8fdb\u884c\u89e3\u51b3\u3002Git\u4f1a\u63d0\u9192\u6211\u4eec\u51b2\u7a81\u7684\u6587\u4ef6\u53ca\u76f8\u5173\u4fe1\u606f\uff0c\u9700\u8981\u624b\u52a8\u4fee\u6539\u4ee3\u7801\u6587\u4ef6\u4e2d\u7684\u4ee3\u7801\uff0c\u7136\u540e\u518d\u4f7f\u7528\u201cgit add\u201d\u547d\u4ee4\u5c06\u4fee\u6539\u540e\u7684\u6587\u4ef6\u6dfb\u52a0\u5230\u6682\u5b58\u533a\uff0c\u6700\u540e\u518d\u4f7f\u7528\u201cgit commit\u201d\u547d\u4ee4\u8fdb\u884c\u63d0\u4ea4\u3002<\/p>\n<p>\u4e94\u3001\u603b\u7ed3<\/p>\n<p>\u5728Git\u4e2d\u5efa\u7acb\u672c\u5730\u5206\u652f\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u4f7f\u7528\u201cgit branch\u201d\u547d\u4ee4\u52a0\u4e0a\u5206\u652f\u540d\u79f0\u5373\u53ef\u3002\u6211\u4eec\u8fd8\u53ef\u4ee5\u5728\u67d0\u4e2a\u63d0\u4ea4\u70b9\u4e0a\u8fdb\u884c\u5206\u652f\u7684\u5efa\u7acb\uff0c\u4ee5\u53ca\u8fdb\u884c\u5206\u652f\u7684\u5408\u5e76\u3002\u4f7f\u7528\u5206\u652f\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u66f4\u597d\u5730\u7ba1\u7406\u548c\u5f00\u53d1\u4ee3\u7801\uff0c\u540c\u65f6\u4e5f\u80fd\u591f\u907f\u514d\u5404\u79cd\u4e92\u76f8\u5e72\u6270\u7684\u95ee\u9898\u7684\u53d1\u751f\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fgit\u5982\u4f55\u5efa\u672c\u5730\u5206\u652f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>git\u662f\u4e00\u6b3e\u975e\u5e38\u6d41\u884c\u7684\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u4f7f\u7528git\u8fdb\u884c\u7248\u672c\u63a7\u5236\u53ef\u4ee5\u8ba9\u6211\u4eec\u66f4\u597d\u5730\u7ba1\u7406\u4ee3\u7801\u3002\u800c\u5728git\u4e2d\uff0c\u5206\u652f\u662f\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u6982\u5ff5\uff0c\u53ef\u4ee5\u5b9e\u73b0\u5bf9\u4ee3\u7801\u7684\u591a\u7248\u672c\u7ba1\u7406\u548c\u5f00\u53d1\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u5728git\u4e2d\u5efa\u7acb\u672c\u5730\u5206\u652f\u3002 \u4e00\u3001\u4ec0\u4e48\u662f\u5206\u652f\uff1f \u5206\u652f\u6307\u7684\u662fGit\u4ed3\u5e93\u4e2d\u7684\u4e00\u6761\u547d\u540d\u7684\u3001\u53ef\u53d8\u7684\u63d0\u4ea4\u94fe\u3002\u5728Git\u4ed3\u5e93\u4e2d\uff0c\u9ed8\u8ba4\u5b58\u5728\u4e00\u4e2a\u540d\u4e3a\u201cmaster\u201d\u7684\u5206\u652f\u3002\u6211\u4eec\u53ef\u4ee5\u5728\u201cmaster\u201d\u5206\u652f\u4e0a\u8fdb\u884c\u63d0\u4ea4\uff0c\u4e5f\u53ef\u4ee5\u5728\u201cmaster\u201d\u5206\u652f\u4e4b\u5916\u5efa\u7acb\u65b0\u7684\u5206\u652f\u8fdb\u884c\u5f00\u53d1\u3002 \u4f7f\u7528\u5206\u652f\u7684\u597d\u5904\u662f\u53ef\u4ee5\u8ba9\u6211\u4eec\u5728\u4ee3\u7801\u5f00\u53d1\u548c\u4fee\u6539\u8fc7\u7a0b\u4e2d\uff0c\u9694\u79bb\u5f53\u524d\u7684\u5f00\u53d1\u4efb\u52a1\uff0c\u4e0d\u4f1a\u5f71\u54cd\u5230\u539f\u6709\u7684\u4ee3\u7801\u3002\u540c\u65f6\uff0c\u5728\u4e0d\u540c\u7684\u5206\u652f\u4e0a\u5f00\u53d1\uff0c\u53ef\u4ee5\u4fdd\u8bc1\u5404\u79cd\u529f\u80fd\u5f00\u53d1\u4e0d\u4f1a\u4e92\u76f8\u5e72\u6270\u3002\u5f53\u9700\u8981\u5c06\u5404\u4e2a\u5206\u652f\u7684\u4ee3\u7801\u5408\u5e76\u65f6\uff0cGit\u4e5f\u63d0\u4f9b\u4e86\u5408\u5e76\u5206\u652f\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u8fdb\u884c\u4ee3\u7801\u5408\u5e76\u3002 \u4e8c\u3001\u5efa\u7acb\u672c\u5730\u5206\u652f \u5728Git\u4e2d\uff0c\u5efa\u7acb\u672c\u5730\u5206\u652f\u975e\u5e38\u7b80\u5355\u3002\u53ea\u9700\u8981\u5728\u5f53\u524d\u4ed3\u5e93\u4e2d\uff0c\u4f7f\u7528\u201cgit branch\u201d\u547d\u4ee4\u52a0\u4e0a\u5206\u652f\u540d\u79f0\u5373\u53ef\u3002\u4f8b\u5982\uff1a $ git branch develop \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u6837\u5c31\u5efa\u7acb\u4e86\u4e00\u4e2a\u540d\u4e3a\u201cdevelop\u201d\u7684\u65b0\u5206\u652f\u3002\u6b64\u65f6\uff0c\u6211\u4eec\u8fd8\u6ca1\u6709\u5207\u6362\u5230\u8be5\u5206\u652f\u4e0a\uff0c\u4f7f\u7528\u201cgit branch\u201d\u547d\u4ee4\u53ef\u4ee5\u67e5\u770b\u5f53\u524d\u6240\u6709\u5206\u652f\u53ca\u5176\u72b6\u6001\u3002 $ git branch * master develop \u767b\u5f55\u540e\u590d\u5236 \u67e5\u770b\u5230\u201c*\u201d\u53f7\u6240\u5728\u7684\u5206\u652f\u5c31\u662f\u5f53\u524d\u6240\u5728\u7684\u5206\u652f\uff0c\u201cmaster\u201d\u662f\u9ed8\u8ba4\u521b\u5efa\u7684\u4e3b\u5206\u652f\uff0c\u800c\u201cdevelop\u201d\u662f\u65b0\u5efa\u7684\u5206\u652f\u3002 \u5982\u679c\u9700\u8981\u5207\u6362\u5230\u201cdevelop\u201d\u5206\u652f\uff0c\u53ef\u4ee5\u4f7f\u7528\u201cgit checkout\u201d\u547d\u4ee4\u8fdb\u884c\u5207\u6362\u3002\u4f8b\u5982\uff1a $ git checkout develop \u767b\u5f55\u540e\u590d\u5236 \u5207\u6362\u5230\u201cdevelop\u201d\u5206\u652f\u540e\uff0c\u53ef\u4ee5\u5728\u8fd9\u4e2a\u5206\u652f\u4e0a\u8fdb\u884c\u4ee3\u7801\u4fee\u6539\u548c\u63d0\u4ea4\u3002\u5982\u679c\u9700\u8981\u67e5\u770b\u5f53\u524d\u6240\u5904\u7684\u5206\u652f\uff0c\u53ef\u4ee5\u4f7f\u7528\u201cgit status\u201d\u547d\u4ee4\u67e5\u770b\u72b6\u6001\u4fe1\u606f\u3002 $ git status On branch develop nothing to commit, working tree clean \u767b\u5f55\u540e\u590d\u5236 \u4e09\u3001\u521b\u5efa\u5206\u652f\u65f6\u57fa\u4e8e\u67d0\u4e2acommit\u70b9 \u5728\u5b9e\u9645\u5f00\u53d1\u4e2d\uff0c\u6211\u4eec\u4e0d\u4ec5\u53ef\u4ee5\u5728\u5f53\u524d\u5206\u652f\u4e0a\u8fdb\u884c\u5206\u652f\u7684\u5efa\u7acb\uff0c\u8fd8\u53ef\u4ee5\u5728\u67d0\u4e2a\u63d0\u4ea4\u70b9\u4e0a\u8fdb\u884c\u5206\u652f\u7684\u5efa\u7acb\u3002\u8fd9\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a $ git branch new_branch_name commit_SHA \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff0c\u201cnew_branch_name\u201d\u662f\u65b0\u5efa\u5206\u652f\u7684\u540d\u79f0\uff0c\u201ccommit_SHA\u201d\u662f\u6307\u5b9a\u7684\u67d0\u4e2a\u63d0\u4ea4\u70b9\u7684commit\u53f7\u3002 \u56db\u3001\u5408\u5e76\u5206\u652f \u5f53\u6211\u4eec\u5728\u4e0d\u540c\u7684\u5206\u652f\u4e0a\u8fdb\u884c\u5f00\u53d1\u5b8c\u6210\u540e\uff0c\u5c31\u53ef\u4ee5\u5c06\u4e24\u4e2a\u5206\u652f\u5408\u5e76\u3002Git\u63d0\u4f9b\u4e86\u4e24\u79cd\u5408\u5e76\u65b9\u5f0f\uff1amerge\u548crebase\u3002\u8fd9\u91cc\u6211\u4eec\u4ee5merge\u4e3a\u4f8b\u8fdb\u884c\u8bb2\u89e3\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-20302","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/20302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=20302"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/20302\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=20302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=20302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=20302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}