{"id":21650,"date":"2024-11-19T09:23:16","date_gmt":"2024-11-19T01:23:16","guid":{"rendered":"https:\/\/fwq.ai\/blog\/21650\/"},"modified":"2024-11-19T09:23:16","modified_gmt":"2024-11-19T01:23:16","slug":"git%e5%91%bd%e4%bb%a4%e8%a1%8c%e6%80%8e%e4%b9%88%e4%bd%bf%e7%94%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/21650\/","title":{"rendered":"git\u547d\u4ee4\u884c\u600e\u4e48\u4f7f\u7528"},"content":{"rendered":"<p><strong>\u547d\u4ee4\u884c\u4f7f\u7528\u6307\u5357<\/strong><\/p>\n<p>Git\u662f\u4e00\u4e2a\u5206\u5e03\u5f0f\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u7528\u4e8e\u8ddf\u8e2a\u4ee3\u7801\u66f4\u6539\u5e76\u534f\u4f5c\u5f00\u53d1\u9879\u76ee\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528Git\uff1a<\/p>\n<p><strong>\u521d\u59cb\u5316Git\u4ed3\u5e93<\/strong><\/p>\n<pre>git init<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u547d\u4ee4\u5c06\u5728\u5f53\u524d\u76ee\u5f55\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Git\u4ed3\u5e93\u3002<\/p>\n<p><strong>\u6dfb\u52a0\u6587\u4ef6\u5230Git<\/strong><\/p>\n<pre>git add &lt;\u6587\u4ef6\u540d&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u547d\u4ee4\u5c06\u6307\u5b9a\u7684\u6587\u4ef6\u6dfb\u52a0\u5230Git\u7684\u6682\u5b58\u533a\u57df\uff0c\u51c6\u5907\u63d0\u4ea4\u3002<\/p>\n<p><strong>\u63d0\u4ea4\u66f4\u6539<\/strong><\/p>\n<pre>git commit -m \"\u63d0\u4ea4\u4fe1\u606f\"<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u547d\u4ee4\u4f1a\u5c06\u6682\u5b58\u533a\u57df\u4e2d\u7684\u66f4\u6539\u63d0\u4ea4\u5230\uff0c\u5e76\u9644\u4e0a\u63d0\u4ea4\u4fe1\u606f\u3002<\/p>\n<p><strong>\u67e5\u770b\u63d0\u4ea4\u5386\u53f2<\/strong><\/p>\n<pre>git log<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u547d\u4ee4\u5c06\u663e\u793a\u6240\u505a\u7684\u6240\u6709\u63d0\u4ea4\u7684\u65e5\u5fd7\u3002<\/p>\n<p><strong>\u67e5\u770b\u6587\u4ef6\u5dee\u5f02<\/strong><\/p>\n<pre>git diff<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u547d\u4ee4\u5c06\u663e\u793a\u5df2\u6682\u5b58\u4f46\u5c1a\u672a\u63d0\u4ea4\u7684\u66f4\u6539\uff0c\u6216\u4e0e\u4e0a\u4e00\u6b21\u63d0\u4ea4\u7684\u66f4\u6539\u3002<\/p>\n<p><strong>\u63a8\u9001\u66f4\u6539\u5230\u8fdc\u7a0b\u4ed3\u5e93<\/strong><\/p>\n<pre>git push origin main<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u547d\u4ee4\u4f1a\u5c06\u672c\u5730\u66f4\u6539\u63a8\u9001\u5230\u540d\u4e3a\u201corigin\u201d\u7684\u8fdc\u7a0b\u4ed3\u5e93\u7684\u201cmain\u201d\u5206\u652f\u3002<\/p>\n<p><strong>\u62c9\u53d6\u8fdc\u7a0b\u66f4\u6539<\/strong><\/p>\n<pre>git pull origin main<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u547d\u4ee4\u4f1a\u5c06\u8fdc\u7a0b\u4ed3\u5e93\u4e2d\u7684\u66f4\u6539\u62c9\u53d6\u5230\u672c\u5730\u4ed3\u5e93\uff0c\u5e76\u5408\u5e76\u5230\u5f53\u524d\u5206\u652f\u3002<\/p>\n<p><strong>\u5206\u652f\u7ba1\u7406<\/strong><\/p>\n<pre>git branch<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u547d\u4ee4\u5c06\u5217\u51fa\u5f53\u524d\u7684\u6240\u6709\u5206\u652f\u3002<\/p>\n<pre>git checkout &lt;\u5206\u652f\u540d&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u547d\u4ee4\u4f1a\u5207\u6362\u5230\u6307\u5b9a\u7684\u5206\u652f\u3002<\/p>\n<pre>git merge &lt;\u5206\u652f\u540d&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u547d\u4ee4\u4f1a\u5c06\u4e24\u4e2a\u5206\u652f\u7684\u66f4\u6539\u5408\u5e76\u5230\u5f53\u524d\u5206\u652f\u3002<\/p>\n<p><strong>\u51b2\u7a81\u89e3\u51b3<\/strong><\/p>\n<p>\u5f53\u5408\u5e76\u4e24\u4e2a\u5206\u652f\u65f6\uff0c\u5982\u679c\u5b58\u5728\u51b2\u7a81\uff0cGit\u4f1a\u63d0\u793a\u4f60\u624b\u52a8\u89e3\u51b3\u5b83\u4eec\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>git add &lt;\u51b2\u7a81\u6587\u4ef6&gt;\ngit commit -m \"\u4fee\u590d\u51b2\u7a81\"<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u4f7f\u7528Git\u547d\u4ee4\u7684\u63d0\u793a<\/strong><\/p>\n<ul>\n<li>\u59cb\u7ec8\u4f7f\u7528\u6e05\u6670\u7684\u63d0\u4ea4\u4fe1\u606f\u3002<\/li>\n<li>\u5b9a\u671f\u63a8\u9001\u66f4\u6539\u5230\u8fdc\u7a0b\u4ed3\u5e93\u3002<\/li>\n<li>\u521b\u5efa\u5206\u652f\u4ee5\u9694\u79bb\u4e0d\u540c\u7684\u5de5\u4f5c\u3002<\/li>\n<li>\u4f7f\u7528\u51b2\u7a81\u89e3\u51b3\u5de5\u5177\u6765\u5e2e\u52a9\u89e3\u51b3\u51b2\u7a81\u3002<\/li>\n<li>\u5229\u7528Git\u6587\u6863\u548c\u6559\u7a0b\u6765\u6df1\u5165\u4e86\u89e3Git\u7684\u529f\u80fd\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u547d\u4ee4\u884c\u600e\u4e48\u4f7f\u7528\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>\u547d\u4ee4\u884c\u4f7f\u7528\u6307\u5357 Git\u662f\u4e00\u4e2a\u5206\u5e03\u5f0f\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u7528\u4e8e\u8ddf\u8e2a\u4ee3\u7801\u66f4\u6539\u5e76\u534f\u4f5c\u5f00\u53d1\u9879\u76ee\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528Git\uff1a \u521d\u59cb\u5316Git\u4ed3\u5e93 git init \u767b\u5f55\u540e\u590d\u5236 \u6b64\u547d\u4ee4\u5c06\u5728\u5f53\u524d\u76ee\u5f55\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Git\u4ed3\u5e93\u3002 \u6dfb\u52a0\u6587\u4ef6\u5230Git git add &lt;\u6587\u4ef6\u540d&gt; \u767b\u5f55\u540e\u590d\u5236 \u6b64\u547d\u4ee4\u5c06\u6307\u5b9a\u7684\u6587\u4ef6\u6dfb\u52a0\u5230Git\u7684\u6682\u5b58\u533a\u57df\uff0c\u51c6\u5907\u63d0\u4ea4\u3002 \u63d0\u4ea4\u66f4\u6539 git commit -m &#8220;\u63d0\u4ea4\u4fe1\u606f&#8221; \u767b\u5f55\u540e\u590d\u5236 \u6b64\u547d\u4ee4\u4f1a\u5c06\u6682\u5b58\u533a\u57df\u4e2d\u7684\u66f4\u6539\u63d0\u4ea4\u5230\uff0c\u5e76\u9644\u4e0a\u63d0\u4ea4\u4fe1\u606f\u3002 \u67e5\u770b\u63d0\u4ea4\u5386\u53f2 git log \u767b\u5f55\u540e\u590d\u5236 \u6b64\u547d\u4ee4\u5c06\u663e\u793a\u6240\u505a\u7684\u6240\u6709\u63d0\u4ea4\u7684\u65e5\u5fd7\u3002 \u67e5\u770b\u6587\u4ef6\u5dee\u5f02 git diff \u767b\u5f55\u540e\u590d\u5236 \u6b64\u547d\u4ee4\u5c06\u663e\u793a\u5df2\u6682\u5b58\u4f46\u5c1a\u672a\u63d0\u4ea4\u7684\u66f4\u6539\uff0c\u6216\u4e0e\u4e0a\u4e00\u6b21\u63d0\u4ea4\u7684\u66f4\u6539\u3002 \u63a8\u9001\u66f4\u6539\u5230\u8fdc\u7a0b\u4ed3\u5e93 git push origin main \u767b\u5f55\u540e\u590d\u5236 \u6b64\u547d\u4ee4\u4f1a\u5c06\u672c\u5730\u66f4\u6539\u63a8\u9001\u5230\u540d\u4e3a\u201corigin\u201d\u7684\u8fdc\u7a0b\u4ed3\u5e93\u7684\u201cmain\u201d\u5206\u652f\u3002 \u62c9\u53d6\u8fdc\u7a0b\u66f4\u6539 git pull origin main \u767b\u5f55\u540e\u590d\u5236 \u6b64\u547d\u4ee4\u4f1a\u5c06\u8fdc\u7a0b\u4ed3\u5e93\u4e2d\u7684\u66f4\u6539\u62c9\u53d6\u5230\u672c\u5730\u4ed3\u5e93\uff0c\u5e76\u5408\u5e76\u5230\u5f53\u524d\u5206\u652f\u3002 \u5206\u652f\u7ba1\u7406 git branch \u767b\u5f55\u540e\u590d\u5236 \u6b64\u547d\u4ee4\u5c06\u5217\u51fa\u5f53\u524d\u7684\u6240\u6709\u5206\u652f\u3002 git checkout &lt;\u5206\u652f\u540d&gt; \u767b\u5f55\u540e\u590d\u5236 \u6b64\u547d\u4ee4\u4f1a\u5207\u6362\u5230\u6307\u5b9a\u7684\u5206\u652f\u3002 git [&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-21650","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21650","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=21650"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21650\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=21650"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=21650"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=21650"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}