{"id":21575,"date":"2024-11-19T17:16:48","date_gmt":"2024-11-19T09:16:48","guid":{"rendered":"https:\/\/fwq.ai\/blog\/21575\/"},"modified":"2024-11-19T17:16:48","modified_gmt":"2024-11-19T09:16:48","slug":"git%e6%80%8e%e4%b9%88%e8%bf%98%e5%8e%9f%e7%89%88%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/21575\/","title":{"rendered":"git\u600e\u4e48\u8fd8\u539f\u7248\u672c"},"content":{"rendered":"<blockquote><p>\n  git \u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u8fd8\u539f\u7248\u672c\uff1a1. \u67e5\u770b\u63d0\u4ea4\u5386\u53f2\u8bb0\u5f55\u5e76\u627e\u5230\u8981\u8fd8\u539f\u7684\u54c8\u5e0c\u503c\uff1b2. \u521b\u5efa\u65b0\u5206\u652f\u4ee5\u907f\u514d\u8986\u76d6\u5f53\u524d\u5de5\u4f5c\uff1b3. \u4f7f\u7528 git reset \u8fd8\u539f\u5230\u6307\u5b9a\u63d0\u4ea4\uff1b4. \u63d0\u4ea4\u8fd8\u539f\u4ee5\u8bb0\u5f55\u5230 git \u5386\u53f2\u8bb0\u5f55\u4e2d\uff1b5. \u5207\u6362\u56de\u4e3b\u5206\u652f\uff08\u53ef\u9009\uff09\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/31\/2024053100340970766.jpg\" class=\"aligncenter\" title=\"git\u600e\u4e48\u8fd8\u539f\u7248\u672c\u63d2\u56fe\" alt=\"git\u600e\u4e48\u8fd8\u539f\u7248\u672c\u63d2\u56fe\" \/><\/p>\n<p><strong>Git \u5982\u4f55\u8fd8\u539f\u7248\u672c<\/strong><\/p>\n<p>Git \u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u5b83\u5141\u8bb8\u5f00\u53d1\u4eba\u5458\u8ffd\u8e2a\u4ee3\u7801\u66f4\u6539\u5e76\u8f7b\u677e\u5730\u8fd8\u539f\u5230\u4ee5\u524d\u7684\u7248\u672c\u3002\u4ee5\u4e0b\u662f\u8fd8\u539f Git \u7248\u672c\u7684\u6b65\u9aa4\uff1a<\/p>\n<p><strong>1. \u627e\u5230\u8981\u8fd8\u539f\u7684\u63d0\u4ea4<\/strong><\/p>\n<p>\u4f7f\u7528  log \u547d\u4ee4\u67e5\u770b\u63d0\u4ea4\u5386\u53f2\u8bb0\u5f55\uff1a<\/p>\n<pre>git log<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u627e\u5230\u8981\u8fd8\u539f\u7684\u63d0\u4ea4\u7684\u54c8\u5e0c\u503c\uff08SHA-1 \u4ee3\u7801\uff09\u3002<\/p>\n<p><strong>2. \u521b\u5efa\u65b0\u5206\u652f<\/strong><\/p>\n<p>\u5728\u8fd8\u539f\u4e4b\u524d\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5206\u652f\u4ee5\u907f\u514d\u8986\u76d6\u5f53\u524d\u5de5\u4f5c\u3002\u4f7f\u7528 git checkout -b \u547d\u4ee4\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre>git checkout -b\u8fd8\u539f\u5206\u652f<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. \u8fd8\u539f\u63d0\u4ea4<\/strong><\/p>\n<p>\u4f7f\u7528 git reset \u547d\u4ee4\u8fd8\u539f\u5230\u6307\u5b9a\u7684\u63d0\u4ea4\uff1a<\/p>\n<pre>git reset &lt;\u63d0\u4ea4\u54c8\u5e0c\u503c&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u547d\u4ee4\u5c06\u91cd\u7f6e\u5f53\u524d\u5206\u652f\uff0c\u4f7f\u5176\u6307\u5411\u6307\u5b9a\u7684\u63d0\u4ea4\u3002<\/p>\n<p><strong>4. \u63d0\u4ea4\u8fd8\u539f<\/strong><\/p>\n<p>\u8fd8\u539f\u540e\uff0c\u63d0\u4ea4\u66f4\u6539\u4ee5\u5c06\u91cd\u7f6e\u8bb0\u5f55\u5230 Git \u5386\u53f2\u8bb0\u5f55\u4e2d\uff1a<\/p>\n<pre>git commit -m \"\u590d\u539f\u7248\u672c\u81f3 &lt;\u63d0\u4ea4\u54c8\u5e0c\u503c&gt;\"<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>5. \u5207\u6362\u56de\u4e3b\u5206\u652f\uff08\u53ef\u9009\uff09<\/strong><\/p>\n<p>\u5982\u679c\u9700\u8981\uff0c\u53ef\u4ee5\u4f7f\u7528 git checkout main \u547d\u4ee4\u5207\u6362\u56de\u4e3b\u5206\u652f\uff1a<\/p>\n<pre>git checkout main<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6ce8\u610f\uff1a<\/strong><\/p>\n<ul>\n<li>\u8fd8\u539f\u64cd\u4f5c\u662f\u4e0d\u53ef\u9006\u7684\u3002\u4e00\u65e6\u63d0\u4ea4\u88ab\u8fd8\u539f\uff0c\u5c31\u4e0d\u80fd\u518d\u6062\u590d\u3002<\/li>\n<li>\u8fd8\u539f\u5c06\u8986\u76d6\u5f53\u524d\u5206\u652f\u4e0a\u6240\u6709\u672a\u63d0\u4ea4\u7684\u66f4\u6539\u3002<\/li>\n<li>\u59cb\u7ec8\u5efa\u8bae\u5728\u8fd8\u539f\u4e4b\u524d\u521b\u5efa\u5907\u4efd\u6216\u514b\u9686\u5b58\u50a8\u5e93\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u8fd8\u539f\u7248\u672c\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 \u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u8fd8\u539f\u7248\u672c\uff1a1. \u67e5\u770b\u63d0\u4ea4\u5386\u53f2\u8bb0\u5f55\u5e76\u627e\u5230\u8981\u8fd8\u539f\u7684\u54c8\u5e0c\u503c\uff1b2. \u521b\u5efa\u65b0\u5206\u652f\u4ee5\u907f\u514d\u8986\u76d6\u5f53\u524d\u5de5\u4f5c\uff1b3. \u4f7f\u7528 git reset \u8fd8\u539f\u5230\u6307\u5b9a\u63d0\u4ea4\uff1b4. \u63d0\u4ea4\u8fd8\u539f\u4ee5\u8bb0\u5f55\u5230 git \u5386\u53f2\u8bb0\u5f55\u4e2d\uff1b5. \u5207\u6362\u56de\u4e3b\u5206\u652f\uff08\u53ef\u9009\uff09\u3002 Git \u5982\u4f55\u8fd8\u539f\u7248\u672c Git \u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u5b83\u5141\u8bb8\u5f00\u53d1\u4eba\u5458\u8ffd\u8e2a\u4ee3\u7801\u66f4\u6539\u5e76\u8f7b\u677e\u5730\u8fd8\u539f\u5230\u4ee5\u524d\u7684\u7248\u672c\u3002\u4ee5\u4e0b\u662f\u8fd8\u539f Git \u7248\u672c\u7684\u6b65\u9aa4\uff1a 1. \u627e\u5230\u8981\u8fd8\u539f\u7684\u63d0\u4ea4 \u4f7f\u7528 log \u547d\u4ee4\u67e5\u770b\u63d0\u4ea4\u5386\u53f2\u8bb0\u5f55\uff1a git log \u767b\u5f55\u540e\u590d\u5236 \u627e\u5230\u8981\u8fd8\u539f\u7684\u63d0\u4ea4\u7684\u54c8\u5e0c\u503c\uff08SHA-1 \u4ee3\u7801\uff09\u3002 2. \u521b\u5efa\u65b0\u5206\u652f \u5728\u8fd8\u539f\u4e4b\u524d\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5206\u652f\u4ee5\u907f\u514d\u8986\u76d6\u5f53\u524d\u5de5\u4f5c\u3002\u4f7f\u7528 git checkout -b \u547d\u4ee4\uff0c\u4f8b\u5982\uff1a git checkout -b\u8fd8\u539f\u5206\u652f \u767b\u5f55\u540e\u590d\u5236 3. \u8fd8\u539f\u63d0\u4ea4 \u4f7f\u7528 git reset \u547d\u4ee4\u8fd8\u539f\u5230\u6307\u5b9a\u7684\u63d0\u4ea4\uff1a git reset &lt;\u63d0\u4ea4\u54c8\u5e0c\u503c&gt; \u767b\u5f55\u540e\u590d\u5236 \u6b64\u547d\u4ee4\u5c06\u91cd\u7f6e\u5f53\u524d\u5206\u652f\uff0c\u4f7f\u5176\u6307\u5411\u6307\u5b9a\u7684\u63d0\u4ea4\u3002 4. \u63d0\u4ea4\u8fd8\u539f \u8fd8\u539f\u540e\uff0c\u63d0\u4ea4\u66f4\u6539\u4ee5\u5c06\u91cd\u7f6e\u8bb0\u5f55\u5230 Git \u5386\u53f2\u8bb0\u5f55\u4e2d\uff1a [&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-21575","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21575","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=21575"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21575\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=21575"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=21575"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=21575"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}