{"id":20365,"date":"2024-11-19T12:18:46","date_gmt":"2024-11-19T04:18:46","guid":{"rendered":"https:\/\/fwq.ai\/blog\/20365\/"},"modified":"2024-11-19T12:18:46","modified_gmt":"2024-11-19T04:18:46","slug":"git%e5%91%bd%e4%bb%a4%e8%a1%8c%e5%a6%82%e4%bd%95%e4%b8%8a%e4%bc%a0%e6%ba%90%e7%a0%81","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/20365\/","title":{"rendered":"git\u547d\u4ee4\u884c\u5982\u4f55\u4e0a\u4f20\u6e90\u7801"},"content":{"rendered":"<p>git \u662f\u73b0\u4ee3\u8f6f\u4ef6\u5f00\u53d1\u884c\u4e1a\u4e2d\u6700\u6d41\u884c\u7684\u4ee3\u7801\u7248\u672c\u63a7\u5236\u5de5\u5177\u4e4b\u4e00\uff0c\u5176\u5f3a\u5927\u7684\u5206\u5e03\u5f0f\u7248\u672c\u63a7\u5236\u7cfb\u7edf\u5177\u6709\u8bb8\u591a\u4f18\u70b9\uff0c\u5305\u62ec\u8ddf\u8e2a\u4ee3\u7801\u53d8\u66f4\u5386\u53f2\u3001\u534f\u4f5c\u5f00\u53d1\u3001\u7248\u672c\u63a7\u5236\u3001\u5206\u652f\u7ba1\u7406\u7b49\u3002<\/p>\n<p>\u5728 Git \u4e2d\uff0c\u4e0a\u4f20\u6e90\u7801\u9700\u8981\u4f7f\u7528\u4ee5\u4e0b\u56db\u4e2a\u57fa\u672c\u547d\u4ee4\u884c\u64cd\u4f5c\uff1a<\/p>\n<ol>\n<li>git add<\/li>\n<li>git commit<\/li>\n<li>git remote<\/li>\n<li>git push<\/li>\n<\/ol>\n<p>\u4e0b\u9762\u8be6\u7ec6\u4ecb\u7ecd\u4e0a\u8ff0\u56db\u4e2a\u57fa\u672c\u547d\u4ee4\u3002<\/p>\n<h3>1. git add<\/h3>\n<p>\u6b64\u547d\u4ee4\u662f\u5c06\u60a8\u7684\u66f4\u6539\u6dfb\u52a0\u5230 Git \u8ddf\u8e2a\u5217\u8868\u4e2d\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u6dfb\u52a0\u6216\u4fee\u6539\u6587\u4ef6\uff0c\u5219\u5e94\u4f7f\u7528\u6b64\u547d\u4ee4\u3002<\/p>\n<p>\u4f7f\u7528\u65b9\u6cd5\uff1a<\/p>\n<pre>$ git add &lt;file-name&gt;&lt;\/file-name&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4f8b\u5982\uff0c\u8981\u5c06 a.html \u6dfb\u52a0\u5230 Git \u8ffd\u8e2a\u5217\u8868\u4e2d\uff0c\u5e94\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>$ git add a.html<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5982\u679c\u60a8\u60f3\u5c06\u60a8\u6240\u505a\u7684\u6240\u6709\u66f4\u6539\u6dfb\u52a0\u5230 Git \u8ffd\u8e2a\u5217\u8868\u4e2d\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>$ git add .<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<h3>2. git commit<\/h3>\n<p>\u6b64\u547d\u4ee4\u5c06\u66f4\u6539\u4fdd\u5b58\u5230 Git \u4e2d\uff0c\u5e76\u6807\u8bb0\u5176\u4e3a\u7248\u672c\u5386\u53f2\u7684\u4e00\u90e8\u5206\u3002\u6bcf\u6b21\u63d0\u4ea4\u65f6\uff0c\u60a8\u90fd\u5e94\u8be5\u8f93\u5165\u81ea\u8ff0\u4fe1\u606f\uff0c\u4ee5\u4fbf\u60a8\u548c\u60a8\u7684\u540c\u4e8b\u4e86\u89e3\u63d0\u4ea4\u66f4\u6539\u7684\u539f\u56e0\u3002<\/p>\n<p>\u4f7f\u7528\u65b9\u6cd5\uff1a<\/p>\n<pre>$ git commit -m \"commit message\"<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u5728 a.html \u6587\u4ef6\u4e2d\u589e\u52a0\u4e86\u4e00\u4e9b\u4ee3\u7801\uff0c\u60a8\u9700\u8981\u63d0\u4ea4\uff08commit\uff09\u7684\u547d\u4ee4\u662f\uff1a<\/p>\n<pre>$ git commit -m \"add some code to a.html\"<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<h3>3. git remote<\/h3>\n<p>\u6b64\u547d\u4ee4\u5b9a\u4e49\u4e0e Git \u4ed3\u5e93\u7684\u8fde\u63a5\u3002\u5f53\u60a8\u4ece\u8fdc\u7a0b\u4ed3\u5e93\u514b\u9686\u6216\u83b7\u53d6\u4ee3\u7801\u65f6\uff0c\u7528\u4e8e\u83b7\u53d6\u66f4\u6539\u3002\u5f53\u60a8\u5c06\u66f4\u6539\u63a8\u9001\u56de\u8fdc\u7a0b\u4ed3\u5e93\u65f6\uff0c\u7528\u4e8e\u4e0a\u4f20\u5df2\u66f4\u6539\u4ee3\u7801\u3002<\/p>\n<p>\u901a\u7528\u65b9\u6cd5\uff1a<\/p>\n<pre>$ git remote add &lt;remote-name&gt;&lt;remote-url&gt;&lt;\/remote-url&gt;&lt;\/remote-name&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4f8b\u5982\uff0c\u5982\u679c\u8981\u5c06\u8fdc\u7a0b\u4ed3\u5e93 \u201corigin\u201d \u4e0e\u9879\u76ee\u7ed1\u5b9a\uff0c\u60a8\u5e94\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>$ git remote add origin https:\/\/github.com\/username\/project.git<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<h3>4. git push<\/h3>\n<p>\u6b64\u547d\u4ee4\u7528\u4e8e\u5c06\u60a8\u7684\u66f4\u6539\u4e0a\u4f20\u5230\u8fdc\u7a0b\u5b58\u50a8\u5e93\u4e2d\uff0c\u4ee5\u4fbf\u5176\u4ed6\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u4f7f\u7528\u548c\u66f4\u65b0\u60a8\u7684\u4ee3\u7801\u3002<\/p>\n<p>\u4f7f\u7528\u65b9\u6cd5\uff1a<\/p>\n<pre>$ git push &lt;remote-name&gt;&lt;branch-name&gt;&lt;\/branch-name&gt;&lt;\/remote-name&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u63d0\u4ea4\u672c\u5730\u66f4\u6539\uff1a<\/p>\n<pre>$ git push origin master<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6b64\u547d\u4ee4\u5c06\u628a\u5f53\u524d\u5206\u652f\u7684\u6240\u6709\u66f4\u6539\u63a8\u9001\u5230\u8fdc\u7a0b\u5b58\u50a8\u5e93\u4e2d\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cmaster\u201d\u7684\u8fdc\u7a0b\u5206\u652f\u3002\u8fd9\u53ef\u4ee5\u6839\u636e\u9700\u8981\u8fdb\u884c\u66f4\u6539\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre>$ git push origin my-feature-branch<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fd9\u5c06\u628a\u5f53\u524d\u5206\u652f\u7684\u6240\u6709\u66f4\u6539\u63a8\u9001\u5230\u8fdc\u7a0b\u5b58\u50a8\u5e93\uff0c\u5e76\u5728\u5b58\u50a8\u5e93\u4e2d\u521b\u5efa\u540d\u4e3a\u201cmy-feature-branch\u201d\u7684\u65b0\u5206\u652f\u3002<\/p>\n<p>\u603b\u7ed3\uff1a<\/p>\n<p>\u4e0a\u4f20\u6e90\u7801\u5230 Git \u5e94\u8be5\u9075\u5faa\u4e0a\u8ff0\u56db\u4e2a\u547d\u4ee4\u7684\u6b65\u9aa4\u3002\u8fd9\u4e9b\u547d\u4ee4\u5c06\u5e2e\u52a9\u60a8\u5c06\u4ee3\u7801\u63d0\u4ea4\u5230\u7248\u672c\u63a7\u5236\u7cfb\u7edf\u4e2d\uff0c\u5e76\u786e\u4fdd\u4ee3\u7801\u53d7\u5230\u8ffd\u8e2a\u548c\u5907\u4efd\u3002\u5b9a\u671f\u66f4\u65b0\u60a8\u7684\u4ee3\u7801\u5e93\u4ee5\u53cd\u6620\u6700\u65b0\u7684\u6539\u52a8\uff0c\u4ee5\u786e\u4fdd\u60a8\u7684\u9879\u76ee\u4fdd\u6301\u4e0e\u4e45\u8fdc\u7684\u540c\u6b65\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fgit\u547d\u4ee4\u884c\u5982\u4f55\u4e0a\u4f20\u6e90\u7801\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\u73b0\u4ee3\u8f6f\u4ef6\u5f00\u53d1\u884c\u4e1a\u4e2d\u6700\u6d41\u884c\u7684\u4ee3\u7801\u7248\u672c\u63a7\u5236\u5de5\u5177\u4e4b\u4e00\uff0c\u5176\u5f3a\u5927\u7684\u5206\u5e03\u5f0f\u7248\u672c\u63a7\u5236\u7cfb\u7edf\u5177\u6709\u8bb8\u591a\u4f18\u70b9\uff0c\u5305\u62ec\u8ddf\u8e2a\u4ee3\u7801\u53d8\u66f4\u5386\u53f2\u3001\u534f\u4f5c\u5f00\u53d1\u3001\u7248\u672c\u63a7\u5236\u3001\u5206\u652f\u7ba1\u7406\u7b49\u3002 \u5728 Git \u4e2d\uff0c\u4e0a\u4f20\u6e90\u7801\u9700\u8981\u4f7f\u7528\u4ee5\u4e0b\u56db\u4e2a\u57fa\u672c\u547d\u4ee4\u884c\u64cd\u4f5c\uff1a git add git commit git remote git push \u4e0b\u9762\u8be6\u7ec6\u4ecb\u7ecd\u4e0a\u8ff0\u56db\u4e2a\u57fa\u672c\u547d\u4ee4\u3002 1. git add \u6b64\u547d\u4ee4\u662f\u5c06\u60a8\u7684\u66f4\u6539\u6dfb\u52a0\u5230 Git \u8ddf\u8e2a\u5217\u8868\u4e2d\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u6dfb\u52a0\u6216\u4fee\u6539\u6587\u4ef6\uff0c\u5219\u5e94\u4f7f\u7528\u6b64\u547d\u4ee4\u3002 \u4f7f\u7528\u65b9\u6cd5\uff1a $ git add &lt;file-name&gt;&lt;\/file-name&gt; \u767b\u5f55\u540e\u590d\u5236 \u4f8b\u5982\uff0c\u8981\u5c06 a.html \u6dfb\u52a0\u5230 Git \u8ffd\u8e2a\u5217\u8868\u4e2d\uff0c\u5e94\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a $ git add a.html \u767b\u5f55\u540e\u590d\u5236 \u5982\u679c\u60a8\u60f3\u5c06\u60a8\u6240\u505a\u7684\u6240\u6709\u66f4\u6539\u6dfb\u52a0\u5230 Git \u8ffd\u8e2a\u5217\u8868\u4e2d\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a $ git add . \u767b\u5f55\u540e\u590d\u5236 2. git commit \u6b64\u547d\u4ee4\u5c06\u66f4\u6539\u4fdd\u5b58\u5230 Git \u4e2d\uff0c\u5e76\u6807\u8bb0\u5176\u4e3a\u7248\u672c\u5386\u53f2\u7684\u4e00\u90e8\u5206\u3002\u6bcf\u6b21\u63d0\u4ea4\u65f6\uff0c\u60a8\u90fd\u5e94\u8be5\u8f93\u5165\u81ea\u8ff0\u4fe1\u606f\uff0c\u4ee5\u4fbf\u60a8\u548c\u60a8\u7684\u540c\u4e8b\u4e86\u89e3\u63d0\u4ea4\u66f4\u6539\u7684\u539f\u56e0\u3002 \u4f7f\u7528\u65b9\u6cd5\uff1a $ git commit -m [&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-20365","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/20365","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=20365"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/20365\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=20365"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=20365"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=20365"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}