{"id":19069,"date":"2024-11-19T16:41:24","date_gmt":"2024-11-19T08:41:24","guid":{"rendered":"https:\/\/fwq.ai\/blog\/19069\/"},"modified":"2024-11-19T16:41:24","modified_gmt":"2024-11-19T08:41:24","slug":"%e4%b8%80%e6%96%87%e6%80%bb%e7%bb%93git%e5%9f%ba%e6%9c%ac%e7%94%a8%e6%b3%95","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/19069\/","title":{"rendered":"\u4e00\u6587\u603b\u7ed3Git\u57fa\u672c\u7528\u6cd5"},"content":{"rendered":"<p>git \u662f\u5f53\u4eca\u6700\u6d41\u884c\u7684\u7248\u672c\u63a7\u5236\u7cfb\u7edf\u4e4b\u4e00\uff0c\u5b83\u53ef\u5e2e\u52a9\u5f00\u53d1\u8005\u7ba1\u7406\u548c\u534f\u8c03\u4ee3\u7801\u7684\u7248\u672c\u3002\u968f\u7740\u56e2\u961f\u9879\u76ee\u589e\u591a\uff0cgit \u7684\u4f7f\u7528\u4e5f\u53d8\u5f97\u8d8a\u6765\u8d8a\u6d41\u884c\u3002\u672c\u6587\u5c06\u4ecb\u7ecd git \u7684\u57fa\u672c\u4f7f\u7528\u3002<\/p>\n<h3>Git \u5b89\u88c5<\/h3>\n<p>\u5b89\u88c5 Git \u662f\u4f7f\u7528 Git \u7684\u524d\u63d0\u3002\u5b89\u88c5\u65b9\u6cd5\u56e0\u4f60\u6240\u7528\u7684\u64cd\u4f5c\u7cfb\u7edf\u800c\u5f02\u3002\u5982\u679c\u4f7f\u7528 Linux \u53d1\u884c\u7248\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u7cfb\u7edf\u81ea\u5e26\u5de5\u5177\u5305\u7ba1\u7406\u5668\u5c06 Git \u5b89\u88c5\u3002<\/p>\n<p>\u4ee5 Debian \u4e3a\u4f8b\uff0c\u4f7f\u7528\u6b64\u547d\u4ee4\u5b89\u88c5 Git\uff1a<\/p>\n<pre>sudo apt-get update\nsudo apt-get install git<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f Windows \u6216 MacOS\uff0c\u5219\u5efa\u8bae\u5230 Git \u7684\u5b98\u7f51\u4e0a\u4e0b\u8f7d\u6700\u65b0\u7248\u672c git.exe \u5b89\u88c5\u5305\uff0c\u6309\u7167\u6307\u793a\u5b89\u88c5\u3002<\/p>\n<h3>\u5f00\u59cb\u4f7f\u7528 Git<\/h3>\n<p>Git \u53ef\u4ee5\u7528\u5728\u4efb\u4f55\u7684\u6587\u4ef6\u5939\u4e2d\u3002\u5982\u679c\u8981\u4f7f\u7528 Git \u7ba1\u7406\u67d0\u4e2a\u4ed3\u5e93\uff0c\u53ef\u4ee5\u8fdb\u5165\u4ed3\u5e93\u6839\u76ee\u5f55\uff0c\u521d\u59cb\u5316 Git \u4ed3\u5e93\uff1a<\/p>\n<pre>git init<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6b64\u547d\u4ee4\u4f1a\u5c06 Git \u4ed3\u5e93\u7684\u72b6\u6001\u521d\u59cb\u5316\uff0c\u5e76\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a .git \u76ee\u5f55\uff0c\u5305\u542b Git \u7684\u6240\u6709\u7ba1\u7406\u4fe1\u606f\u3002<\/p>\n<h3>Git \u57fa\u672c\u64cd\u4f5c<\/h3>\n<ol>\n<li>\u67e5\u770b\u4ed3\u5e93\u7684\u72b6\u6001<\/li>\n<\/ol>\n<p>\u4f7f\u7528\u4e0b\u5217\u547d\u4ee4\uff0c\u67e5\u770b Git \u4ed3\u5e93\u7684\u72b6\u6001\uff1a<\/p>\n<pre>git status<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8f93\u51fa\u7684\u7ed3\u679c\u544a\u8bc9\u4f60\u5f53\u524d\u5206\u652f\u548c\u4ed3\u5e93\u72b6\u6001\uff0c\u5305\u62ec\uff1a<\/p>\n<pre>On branch master\nnothing to commit, working directory clean<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8868\u793a\u5f53\u524d\u5206\u652f\u662f\u4e3b\u5206\u652f\uff0c\u6ca1\u6709\u65b0\u7684\u53d8\u66f4\uff0c\u5de5\u4f5c\u76ee\u5f55\u5e72\u51c0\u3002<\/p>\n<ol>\n<li>\u6dfb\u52a0\u6587\u4ef6<\/li>\n<\/ol>\n<p>\u5728 Git \u4ed3\u5e93\u7ba1\u7406\u7684\u76ee\u5f55\u4e2d\uff0c\u6bcf\u5f53\u4f60\u7f16\u8f91\u4e86\u4e00\u4e2a\u6587\u4ef6\u65f6\uff0c\u4f60\u9700\u8981\u544a\u8bc9 Git \u628a\u6587\u4ef6\u6dfb\u52a0\u5230\u4ed3\u5e93\u3002\u6b64\u547d\u4ee4\u5c06\u4f60\u7684\u5de5\u4f5c\u76ee\u5f55\u4e0b\u7684\u8f6c\u6362\u4e3a\u4e00\u4e2a Git \u4ed3\u5e93\u80fd\u591f\u8ddf\u8e2a\u7684\u6587\u4ef6\uff1a<\/p>\n<pre>git add filename<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5982\u679c\u8981\u6dfb\u52a0\u6574\u4e2a\u76ee\u5f55\uff0c\u8bf7\u4f7f\u7528\u4e0b\u5217\u547d\u4ee4\uff1a<\/p>\n<pre>git add .<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li>\u63d0\u4ea4\u53d8\u66f4<\/li>\n<\/ol>\n<p>\u6dfb\u52a0\u6216\u4fee\u6539\u6587\u4ef6\u540e\uff0c\u5e94\u8be5\u7528\u547d\u4ee4\u63d0\u4ea4\u53d8\u66f4\uff1a<\/p>\n<pre>git commit -m \"commit message\"<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5176\u4e2d\uff0ccommit message \u662f\u5bf9\u4f60\u6240\u505a\u7684\u4fee\u6539\u7684\u7b80\u8981\u4ecb\u7ecd\u3002<\/p>\n<ol>\n<li>\u67e5\u770b\u63d0\u4ea4\u5386\u53f2<\/li>\n<\/ol>\n<p>\u901a\u8fc7\u67e5\u770b\u63d0\u4ea4\u5386\u53f2\uff0c\u4f60\u53ef\u4ee5\u4e86\u89e3\u5230\u4ed3\u5e93\u4e2d\u7684\u6240\u6709\u63d0\u4ea4\u548c\u66f4\u6539\u3002\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u67e5\u770b\u63d0\u4ea4\u5386\u53f2\uff1a<\/p>\n<pre>git log<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fd9\u5c06\u8f93\u51fa\u8fdb\u5165\u63d0\u4ea4\u5386\u53f2\u4ee5\u6765\u7684\u6240\u6709\u63d0\u4ea4\u53d6\u6d88\u4ee4\uff0c\u5305\u62ec\u63d0\u4ea4\u65f6\u95f4\u3001\u4f5c\u8005\u3001\u6807\u9898\u3001\u63d0\u4ea4\u8bf4\u660e\u548c SHA-1 \u6563\u5217\uff1a<\/p>\n<pre>commit 6983f89439dbf09dc1a66207ed830f1a54630f7f (HEAD -&gt; master)\nAuthor: Tom &lt;tom@acme.com&gt;\nDate:   Thu Nov 22 01:51:13 2018 -0500\n\n    Add new feature\n\ncommit e028ac9be18c313bdb96bfc3c3cd0d8fbf7c6c1b\nAuthor: Tom &lt;tom@acme.com&gt;\nDate:   Wed Nov 21 11:51:13 2018 -0500\n\n    Initial commit<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fd9\u4e9b\u5386\u53f2\u8bb0\u5f55\u4fe1\u606f\u53ef\u4ee5\u5e2e\u52a9\u4f60\u4e86\u89e3\u5404\u4e2a\u63d0\u4ea4\u4e4b\u95f4\u7684\u73af\u5883\u72b6\u6001\u4ee5\u53ca\u5b83\u4eec\u5bf9\u5e94\u7684\u63d0\u4ea4\u3002<\/p>\n<ol>\n<li>\u5206\u652f\u548c\u5408\u5e76<\/li>\n<\/ol>\n<p>Git \u5141\u8bb8\u4f7f\u7528\u65b9\u4fbf\u7684 git merge \u547d\u4ee4\u6765\u5c06\u4e0d\u540c\u7684\u5206\u652f\u5408\u5e76\u5230\u4e00\u8d77\u3002\u4f8b\u5982\uff0c\u82e5\u8981\u5408\u5e76 master \u5206\u652f\u548c dev \u5206\u652f\uff0c\u5728 master \u4e0a\u8fd0\u884c\uff1a<\/p>\n<pre>git merge dev<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<h3>\u603b\u7ed3<\/h3>\n<p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u4e86\u89e3\u4e86 Git \u7684\u57fa\u672c\u7528\u6cd5\uff0c\u5982\u5b89\u88c5 Git\u3001\u521d\u59cb\u5316 Git \u4ed3\u5e93\u3001\u6dfb\u52a0\u6587\u4ef6\u3001\u63d0\u4ea4\u53d8\u66f4\u3001\u67e5\u770b\u63d0\u4ea4\u5386\u53f2\u3001\u5206\u652f\u548c\u5408\u5e76\u7b49\u7b49\u3002\u5b66\u4f1a\u4f7f\u7528\u8fd9\u4e9b\u57fa\u672c\u529f\u80fd\u540e\uff0c\u4f60\u5c31\u53ef\u4ee5\u901a\u8fc7 Git \u66f4\u8f7b\u677e\u5730\u7ba1\u7406\u548c\u534f\u8c03\u4ee3\u7801\u7684\u7248\u672c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4e00\u6587\u603b\u7ed3Git\u57fa\u672c\u7528\u6cd5\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\u5f53\u4eca\u6700\u6d41\u884c\u7684\u7248\u672c\u63a7\u5236\u7cfb\u7edf\u4e4b\u4e00\uff0c\u5b83\u53ef\u5e2e\u52a9\u5f00\u53d1\u8005\u7ba1\u7406\u548c\u534f\u8c03\u4ee3\u7801\u7684\u7248\u672c\u3002\u968f\u7740\u56e2\u961f\u9879\u76ee\u589e\u591a\uff0cgit \u7684\u4f7f\u7528\u4e5f\u53d8\u5f97\u8d8a\u6765\u8d8a\u6d41\u884c\u3002\u672c\u6587\u5c06\u4ecb\u7ecd git \u7684\u57fa\u672c\u4f7f\u7528\u3002 Git \u5b89\u88c5 \u5b89\u88c5 Git \u662f\u4f7f\u7528 Git \u7684\u524d\u63d0\u3002\u5b89\u88c5\u65b9\u6cd5\u56e0\u4f60\u6240\u7528\u7684\u64cd\u4f5c\u7cfb\u7edf\u800c\u5f02\u3002\u5982\u679c\u4f7f\u7528 Linux \u53d1\u884c\u7248\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u7cfb\u7edf\u81ea\u5e26\u5de5\u5177\u5305\u7ba1\u7406\u5668\u5c06 Git \u5b89\u88c5\u3002 \u4ee5 Debian \u4e3a\u4f8b\uff0c\u4f7f\u7528\u6b64\u547d\u4ee4\u5b89\u88c5 Git\uff1a sudo apt-get update sudo apt-get install git \u767b\u5f55\u540e\u590d\u5236 \u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f Windows \u6216 MacOS\uff0c\u5219\u5efa\u8bae\u5230 Git \u7684\u5b98\u7f51\u4e0a\u4e0b\u8f7d\u6700\u65b0\u7248\u672c git.exe \u5b89\u88c5\u5305\uff0c\u6309\u7167\u6307\u793a\u5b89\u88c5\u3002 \u5f00\u59cb\u4f7f\u7528 Git Git \u53ef\u4ee5\u7528\u5728\u4efb\u4f55\u7684\u6587\u4ef6\u5939\u4e2d\u3002\u5982\u679c\u8981\u4f7f\u7528 Git \u7ba1\u7406\u67d0\u4e2a\u4ed3\u5e93\uff0c\u53ef\u4ee5\u8fdb\u5165\u4ed3\u5e93\u6839\u76ee\u5f55\uff0c\u521d\u59cb\u5316 Git \u4ed3\u5e93\uff1a git init \u767b\u5f55\u540e\u590d\u5236 \u6b64\u547d\u4ee4\u4f1a\u5c06 Git \u4ed3\u5e93\u7684\u72b6\u6001\u521d\u59cb\u5316\uff0c\u5e76\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a .git \u76ee\u5f55\uff0c\u5305\u542b Git \u7684\u6240\u6709\u7ba1\u7406\u4fe1\u606f\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-19069","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/19069","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=19069"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/19069\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=19069"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=19069"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=19069"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}