{"id":37208,"date":"2023-05-14T05:08:58","date_gmt":"2022-12-19T03:51:38","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/git-reset%e5%92%8cgit-revert%e7%9a%84%e5%8c%ba%e5%88%ab%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f\/"},"modified":"2024-04-30T04:03:29","modified_gmt":"2024-04-29T20:03:29","slug":"git-reset%e5%92%8cgit-revert%e7%9a%84%e5%8c%ba%e5%88%ab%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/git-reset%e5%92%8cgit-revert%e7%9a%84%e5%8c%ba%e5%88%ab%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f\/","title":{"rendered":"git reset\u548cgit revert\u7684\u533a\u522b\u662f\u4ec0\u4e48\uff1f"},"content":{"rendered":"<h2>\u9996\u5148<\/h2>\n<p>\u8fd9\u662f\u8239\u4e95\u603b\u7814\u6570\u5b57\u90e8\u95e8\u7684OSW\u3002\u7531\u4e8e\u9700\u6c42\u6682\u6401\uff0c\u6211\u8fdb\u884c\u4e86\u6839\u636e\u6211\u4eec\u4e1a\u52a1\u4f7f\u7528\u7684\u8fdc\u7a0b\u4ee3\u7801\u5e93\u7684\u4e00\u4e2a\u5206\u652f\u8fdb\u884c\u8fd8\u539f\u7684\u64cd\u4f5c\u3002\u5728\u64cd\u4f5c\u8fc7\u7a0b\u4e2d\uff0c\u7531\u4e8egit revet\u548cgit reset\u6df7\u4e71\u4e0d\u6e05\uff0c\u6211\u5c06\u8fdb\u884c\u6574\u7406\u3002<\/p>\n<h2>\u7d50\u8ad6 &#8211; \u4ece\u4e2d\u56fd\u7684\u672c\u571f\u89d2\u5ea6\u51fa\u53d1\u8fdb\u884c\u7ffb\u8bd1\uff0c\u53ea\u9700\u8981\u63d0\u4f9b\u4e00\u79cd\u9009\u9879 \uff1a<\/h2>\n<p>\u603b\u7ed3<\/p>\n<p>\u8fd9\u4e24\u8005\u5728\u6062\u590d\u63d0\u4ea4\u72b6\u6001\u4e0a\u662f\u76f8\u540c\u7684\uff0c\u4f46\u6839\u636e\u4e0b\u9762\u7684\u63cf\u8ff0\u4f3c\u4e4e\u6709\u5982\u4e0b\u7684\u533a\u522b\u3002\uff08\u7528\u9014\u662f\u6211\u7684\u4e3b\u89c2\u770b\u6cd5\uff09<\/p>\n<div>\n<div class=\"post-table\">\u9805\u76eegit resetgit revert\u623b\u3057\u305f\u6642\u70b9\u307e\u3067\u306e\u30b3\u30df\u30c3\u30c8\u5c65\u6b74\u304c\u6b8b\u308bXO\u300c\u623b\u3057\u305f\u3068\u3044\u3046\u30b3\u30df\u30c3\u30c8\u300d\u304c\u7a4d\u307e\u308c\u308bXO\u30ea\u30e2\u30fc\u30c8\u30ea\u30dd\u30b8\u30c8\u30ea\u3078\u305d\u306e\u307e\u307epush\u3067\u304d\u308bXO\u7528\u9014\u500b\u4eba\u958b\u767a\u30c1\u30fc\u30e0\u958b\u767a<\/div>\n<\/div>\n<p>\u5982\u679c\u91cd\u7f6e\uff08reset\uff09\u7684\u8bdd\uff0c\u7248\u672c\u8bb0\u5f55\u4f1a\u56de\u5230\u8be5\u65f6\u523b\uff0c\u56e0\u6b64\u4ece\u56de\u6eda\u7684\u65f6\u523b\u5f00\u59cb\uff0c\u540e\u7eed\u7684\u7248\u672c\u8bb0\u5f55\u5c06\u4e0d\u518d\u53ef\u89c1\u3002\u800c\u8fd8\u539f\uff08revert\uff09\u4f1a\u5c06\u5b58\u50a8\u5e93\u72b6\u6001\u56de\u6eda\u5230\u8be5\u65f6\u523b\uff0c\u4f46\u662f\u7248\u672c\u8bb0\u5f55\u4fdd\u6301\u4e0d\u53d8\uff0c\u5e76\u4e14\u4f1a\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684\u201c\u56de\u6eda\u201d\u63d0\u4ea4\u3002<\/p>\n<p>\u5728\u4e0a\u8ff0\u7684\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u5c1d\u8bd5\u5c06\u8fdb\u884c\u8fc7\u56de\u6eda\uff08reset\uff09\u7684\u5b58\u50a8\u5e93\u8fdb\u884c\u63a8\u9001\uff0c\u7531\u4e8e\u5b83\u53d8\u5f97\u6bd4\u8fdc\u7a0b\u5b58\u50a8\u5e93\u66f4\u65e7\uff0c\u6240\u4ee5\u5fc5\u987b\u4f7f\u7528-f\u9009\u9879\u8fdb\u884c\u5f3a\u5236\u6267\u884c\u624d\u80fd\u8fdb\u884c\u63a8\u9001\u3002\u53e6\u4e00\u65b9\u9762\uff0c\u64a4\u9500\uff08revert\uff09\u4f1a\u4fdd\u7559\u63d0\u4ea4\u5386\u53f2\u8bb0\u5f55\uff0c\u5e76\u5c06\u4e00\u4e2a\u65b0\u7684\u201c\u56de\u6eda\u201d\u63d0\u4ea4\u5806\u53e0\u5728\u4e0a\u9762\uff0c\u56e0\u6b64\u53ef\u4ee5\u76f4\u63a5\u63a8\u9001\u5230\u8fdc\u7a0b+\u03b1\u72b6\u6001\u3002<\/p>\n<p>\u5ffd\u7565push\u7684\u95ee\u9898\uff0c\u901a\u8fc7reset\u540e\u52a0\u5165\u4e00\u4e2a\u7a7a\u63d0\u4ea4\u5e76\u5728\u63d0\u4ea4\u6d88\u606f\u4e2d\u8865\u5145revert\u7684\u4fe1\u606f\u662f\u53ef\u884c\u7684\uff0c\u4f46\u662f\u7531\u4e8e\u5df2\u91cd\u7f6e\u7684\u63d0\u4ea4\u5386\u53f2\u4f1a\u6d88\u5931\uff0c\u56e0\u6b64\u5c06\u8981\u56de\u6eda\u7684\u6240\u6709\u64cd\u4f5c\u7684\u63d0\u4ea4\u90fd\u8fdb\u884c\u5168\u9762\u63cf\u8ff0\u53ef\u80fd\u4f1a\u5f88\u56f0\u96be\u3002<\/p>\n<p>\u91cd\u7f6e(reset)\u4f3c\u4e4e\u662f\u5728\u672c\u5730\u5b58\u50a8\u5e93\u51fa\u9519\u65f6\u4f7f\u7528\u7684\u89e3\u51b3\u65b9\u6cd5\u3002\u5728\u521b\u5efa\u6210\u679c\u7269\u7684\u8fc7\u7a0b\u4e2d\uff0c\u201c\u64a4\u9500\u4e0d\u5fc5\u8981\u7684\u64cd\u4f5c\u201d\u8fd9\u6837\u7684\u63d0\u4ea4(revert)\u5728\u5386\u53f2\u8bb0\u5f55\u4e2d\u4fdd\u7559\u4e0b\u6765\u662f\u6ca1\u6709\u610f\u4e49\u7684\uff0c\u800c\u4e14\u5982\u679c\u63a8\u9001(push)\u4e86\u4e4b\u540e\uff0c\u8fdc\u7a0b\u5b58\u50a8\u5e93\u7684\u63d0\u4ea4\u5386\u53f2\u53ef\u80fd\u4f1a\u53d8\u5f97\u6df7\u4e71\u4e0d\u582a\u3002<\/p>\n<h2>\u5b66\u4e60\u73af\u5883 &#8211;<\/h2>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Windows 11 (WSL2 Ubuntu)<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">VSCode 1.76.2<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">Git 2.34.1<\/ul>\n<h2>\u9a8c\u8bc1\u73af\u5883<\/h2>\n<p>\u4e3a\u4e86\u7b80\u5316\u5bf9\u8bdd\uff0c\u6211\u4f1a\u5728\u672c\u5730\u4ed3\u5e93\u4e2d\u521b\u5efa\u4e0b\u9762\u7684README\uff0c\u5e76\u5bf9\u5176\u8fdb\u884c\u4fee\u6539\u548c\u9a8c\u8bc1\u3002<\/p>\n<p>\u6587\u4ef6\u4f1a\u9010\u6e10\u52a0\u5165\u5dee\u5f02\uff0c\u4f46\u57fa\u672c\u4e0a\u53ea\u4f1a\u6dfb\u52a0\u6216\u5220\u9664\u6807\u9898\u3002<\/p>\n<ul class=\"post-ul\">\u4f5c\u6210\u3059\u308bREADME<\/ul>\n<pre class=\"post-pre\"><code><span class=\"gu\">## A<\/span>\r\nA\r\nA\r\n\r\n<span class=\"gu\">## B<\/span>\r\nB\r\nB\r\n\r\n<span class=\"gu\">## C<\/span>\r\nC\r\nC\r\n\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d2d1937434c4406c5033a\/16-0.png\" alt=\"image.png\" \/><\/div>\n<h2>\u57fa\u790e\u77e5\u8b58<\/h2>\n<p>\u5728\u6307\u5b9a\u63d0\u4ea4\u5386\u53f2\u65f6\uff0c\u4f1a\u4f7f\u7528HEAD\u3001@\u4ee5\u53ca\u52a0\u4e0a&#8221;~&#8221;\u3001&#8221;^&#8221;\u7b49\u7b26\u53f7\uff0c\u8fd9\u4e9b\u7b26\u53f7\u7684\u542b\u4e49\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\u8be6\u7ec6\u89e3\u91ca\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u7136\u800c\uff0c\u6839\u636e\u5408\u5e76\u7684\u60c5\u51b5\uff0c\u4f3c\u4e4e\u4f7f\u7528&#8221;~&#8221;\u548c&#8221;^&#8221;\u4f1a\u6709\u4e0d\u540c\u7684\u884c\u4e3a\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u9996\u5148\uff0cgit reset\u662f\u4ec0\u4e48<\/h2>\n<p>\u6211\u8ba4\u4e3a\u6839\u636e\u4e0d\u540c\u7684\u9009\u9879\uff0c\u91cd\u7f6e\u7684\u64cd\u4f5c\u65b9\u5f0f\u4f1a\u6709\u6240\u53d8\u5316\uff0c\u4e0d\u8fc7\u8fd9\u7bc7\u6587\u7ae0\u975e\u5e38\u6613\u61c2\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u9996\u5148\uff0cgit revert\u662f\u4ec0\u4e48\u610f\u601d\uff1f<\/h2>\n<p>revert\u7684\u610f\u601d\u4f3c\u4e4e\u662f\u56de\u5fa9\u5230\u539f\u4f86\u7684\u7fd2\u6163\u6216\u72c0\u614b\u3002<\/p>\n<blockquote><p>\u8fd4\u56de\u539f\u6765\u7684\u4e60\u60ef\u3001\u72b6\u6001\u7b49\u3002<\/p><\/blockquote>\n<p>\u5728git\u4e2d\uff0c\u56de\u6eda\uff08revert\uff09\u662f\u5c06\u5b58\u50a8\u5e93\u6062\u590d\u5230\u7279\u5b9a\u63d0\u4ea4\u72b6\u6001\uff0c\u5e76\u53e0\u52a0\u4e00\u4e2a\u6307\u793a\u5df2\u56de\u6eda\u64cd\u4f5c\u7684\u63d0\u4ea4\u3002<\/p>\n<p>\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4e0e\u91cd\u7f6e\u4e0d\u540c\uff0c\u63d0\u4ea4\u5386\u53f2\u4ecd\u7136\u4fdd\u7559\uff0c\u65b0\u7684\u66f4\u6539\u4f1a\u5728\u5176\u4e0a\u9762\u53e0\u52a0\u3002(\u5728Git\u4e2d\uff0c\u6062\u590d\u64cd\u4f5c\u88ab\u79f0\u4e3a&#8221;\u6253\u6d88&#8221;\u3002)<\/p>\n<h3>\u8bd5\u7740\u8fd8\u539f\u6700\u8fd1\u7684\u63d0\u4ea4<\/h3>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u5c1d\u8bd5\u64a4\u9500\u5728\u9a8c\u8bc1\u73af\u5883\u4e2d\u521b\u5efa\u7684\u5b58\u50a8\u5e93\u4e2d\u6dfb\u52a0&#8221;\u6807\u9898C&#8221;\u7684\u6700\u65b0\u63d0\u4ea4\u3002<\/p>\n<p>\u7136\u540e\uff0c\u6807\u9898C\u88ab\u5220\u9664\uff08\u4fdd\u7559\u6dfb\u52a0\u6807\u9898C\u7684\u63d0\u4ea4\u8bb0\u5f55\uff09\uff0c\u5e76\u6dfb\u52a0\u4e86\u4e00\u4e2a\u8868\u660e\u8fdb\u884crevert\u7684\u63d0\u4ea4\u8bb0\u5f55\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d2d1937434c4406c5033a\/33-0.png\" alt=\"image.png\" \/><\/div>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span>git revert @\r\n<span class=\"c\"># \u30b3\u30df\u30c3\u30c8\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u7de8\u96c6\u3057\u3001\u4fdd\u5b58\u3057\u3066\u5b8c\u4e86<\/span>\r\n<\/code><\/pre>\n<ul class=\"post-ul\">revert\u5f8c\u306eREADME<\/ul>\n<pre class=\"post-pre\"><code><span class=\"gu\">## A<\/span>\r\nA\r\nA\r\n\r\n<span class=\"gu\">## B<\/span>\r\nB\r\nB\r\n\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d2d1937434c4406c5033a\/37-0.png\" alt=\"image.png\" \/><\/div>\n<h3>\u5c1d\u8bd5\u8fd8\u539f\u8fde\u7eed\u7684\u63d0\u4ea4<\/h3>\n<p>\u4e0b\u9762\u662f\u4e00\u4e2a\u53ef\u80fd\u7684\u4e2d\u6587\u7ffb\u8bd1\u7248\u672c\uff1a<br \/>\n\u63a5\u4e0b\u6765\u6211\u4eec\u5c06\u5c1d\u8bd5\u64a4\u9500\u8fde\u7eed\u7684\u63d0\u4ea4\u3002\u7531\u4e8e\u4e4b\u524d\u5df2\u7ecf\u64a4\u9500\u8fc7\u4e00\u6b21\uff0c\u6240\u4ee5\u6211\u4eec\u5c06\u6062\u590d\u5230\u5728\u9a8c\u8bc1\u73af\u5883\u4e2d\u521b\u5efa\u7684\u72b6\u6001\uff0c\u56de\u5230\u64a4\u9500\u4e4b\u524d\u7684\u72b6\u6001\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"c\"># \u30b3\u30df\u30c3\u30c8\u306e\u30cf\u30c3\u30b7\u30e5\u5024\u3092\u78ba\u8a8d<\/span>\r\n<span class=\"nv\">$ <\/span>git log <span class=\"nt\">--oneline<\/span>\r\nf20946b <span class=\"o\">(<\/span>HEAD -&gt; revert<span class=\"o\">)<\/span> Revert <span class=\"s2\">\"\u8ffd\u52a0: \u898b\u51fa\u3057C\"<\/span>\r\n37cbc2e <span class=\"o\">(<\/span>master<span class=\"o\">)<\/span> \u8ffd\u52a0: \u898b\u51fa\u3057C\r\n11acd6f \u8ffd\u52a0: \u898b\u51fa\u3057B\r\n4ea1d6d \u8ffd\u52a0:  \u898b\u51fa\u3057A\r\nc9c6945 initial commit\r\n\r\n<span class=\"c\"># revert\u524d\u306e\u300c37cbc2e\u300d\u306b\u623b\u3059<\/span>\r\n<span class=\"nv\">$ <\/span>git reset <span class=\"nt\">--hard<\/span> 37cbc2e\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d2d1937434c4406c5033a\/41-0.png\" alt=\"image.png\" \/><\/div>\n<p>\u6211\u5011\u5c07\u56de\u5fa9\u9023\u7e8c\u7684\u63d0\u4ea4\u3002\u5728\u9019\u88e1\uff0c\u6211\u5011\u5c07\u56de\u5fa9\u6a19\u984cC\u3001B\u3002<\/p>\n<p>\u5982\u679c\u8981\u64a4\u9500\u8fde\u7eed\u7684\u63d0\u4ea4\uff0c\u53ef\u4ee5\u4f7f\u7528&#8221;&#8230;&#8221;\u5c06\u5f53\u524d\u63d0\u4ea4\u4e0e\u8981\u64a4\u9500\u7684\u63d0\u4ea4\u8fde\u63a5\u8d77\u6765\uff0c\u5e76\u76f8\u5bf9\u63cf\u8ff0\u3002\u56e0\u4e3a\u4f1a\u64a4\u9500\u5230\u6307\u5b9a\u53f3\u8fb9\u63d0\u4ea4\u7684\u524d\u4e00\u4e2a\u63d0\u4ea4\uff0c\u6240\u4ee5\u4f1a\u6062\u590d\u5230\u6307\u5b9a\u53f3\u8fb9\u63d0\u4ea4\u7684\u72b6\u6001\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"c\"># \u73fe\u5728\u306e\u30b3\u30df\u30c3\u30c8\u304b\u30894\u500b\u524d\u306e\u30b3\u30df\u30c3\u30c8\u307e\u3067\u3092revert\u3059\u308b<\/span>\r\n<span class=\"nv\">$ <\/span>git revert @...@~5\r\n\r\n<span class=\"c\"># 4\u500b\u5206\u306e\u30b3\u30df\u30c3\u30c8\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u7de8\u96c6\u3001\u4fdd\u5b58\u3057\u3066\u5b8c\u4e86<\/span>\r\n<\/code><\/pre>\n<p>\u5b9e\u9645\u4e0a\u8fd0\u884c\u547d\u4ee4\u540e\uff0c\u4f1a\u6253\u5f00\u4fee\u6539\u56db\u6b21\u63d0\u4ea4\u6d88\u606f\u7684\u754c\u9762\uff0c\u50cf\u4e0a\u9762\u7684\u793a\u4f8b\u4e00\u6837\u3002\u5982\u679c\u6570\u91cf\u8fc7\u591a\u4f1a\u5f88\u9ebb\u70e6\uff0c\u6240\u4ee5\u53ef\u4ee5\u901a\u8fc7\u6307\u5b9a&#8211;no-edit\u6765\u8df3\u8fc7\u7f16\u8f91\u6d88\u606f\u7684\u6b65\u9aa4\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span>git revert <span class=\"nt\">--no-edit<\/span> @...@~2\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d2d1937434c4406c5033a\/47-0.png\" alt=\"image.png\" \/><\/div>\n<h4>\u4e0d\u8981\u5728\u56de\u9000\u540e\u81ea\u52a8\u63d0\u4ea4<\/h4>\n<p>\u5982\u679c\u4ee5\u9ed8\u8ba4\u8bbe\u7f6e\u8fd0\u884crevert\uff0c\u5219\u4ec5\u4f1a\u6dfb\u52a0\u4e00\u4e2a\u8868\u793a&#8221;revert\u6240\u6d89\u53ca\u7684\u63d0\u4ea4&#8221;\u7684\u63d0\u4ea4\u3002\u901a\u8fc7\u6307\u5b9a-n\u9009\u9879\uff0c\u5373\u4f7f\u8fdb\u884c\u4e86revert\u64cd\u4f5c\uff0c\u4e5f\u4e0d\u4f1a\u81ea\u52a8\u63d0\u4ea4\u3002<\/p>\n<p>\u9996\u5148\u5c06\u73af\u5883\u6062\u590d\u5230\u9a8c\u8bc1\u4e4b\u524d\u7684\u72b6\u6001\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span>git reset <span class=\"nt\">--hard<\/span> 37cbc2e\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span>git revert <span class=\"nt\">-n<\/span> @...@~2\r\n<span class=\"nv\">$ <\/span>git status\r\nOn branch revert\r\nYou are currently reverting commit 11acd6f.\r\n  <span class=\"o\">(<\/span>all conflicts fixed: run <span class=\"s2\">\"git revert --continue\"<\/span><span class=\"o\">)<\/span>\r\n  <span class=\"o\">(<\/span>use <span class=\"s2\">\"git revert --skip\"<\/span> to skip this patch<span class=\"o\">)<\/span>\r\n  <span class=\"o\">(<\/span>use <span class=\"s2\">\"git revert --abort\"<\/span> to cancel the revert operation<span class=\"o\">)<\/span>\r\n\r\nChanges to be committed:\r\n  <span class=\"o\">(<\/span>use <span class=\"s2\">\"git restore --staged &lt;file&gt;...\"<\/span> to unstage<span class=\"o\">)<\/span>\r\n        modified:   README.md\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d2d1937434c4406c5033a\/53-0.png\" alt=\"image.png\" \/><\/div>\n<p>\u82e5\u6307\u5b9a\u4e86\u201c-n\u201d\uff0c\u9996\u5148\u4f1a\u901a\u8fc7revert\u5c06\u63d0\u4ea4\u7684\u72b6\u6001\u6062\u590d\u3002\u8fd9\u65f6\uff0c\u5de5\u4f5c\u5185\u5bb9\u5c06\u4f1a\u6062\u590d\u5e76\u5904\u4e8e\u5df2\u6dfb\u52a0\u7684\u72b6\u6001\uff08git add\uff09\u3002\u56e0\u6b64\uff0c\u201c\u5df2\u56de\u6eda\u201d\u7684\u591a\u4e2a\u63d0\u4ea4\u4e0d\u4f1a\u81ea\u52a8\u5806\u53e0\uff0c\u4f46\u53ef\u4ee5\u624b\u52a8\u63d0\u4ea4\u5b83\u4eec\u4ee5\u5c06\u8fd9\u4e9b\u591a\u4e2a\u63d0\u4ea4\u5408\u5e76\u4e3a\u4e00\u4e2a\u3002<\/p>\n<p>\u4e3a\u4e86\u907f\u514d\u65e5\u540e\u4e0d\u6e05\u695a\u662f\u5426\u6709\u8fd8\u539f\u8fc7\u7684\u63d0\u4ea4\uff0c\u5efa\u8bae\u81f3\u5c11\u5b58\u5728\u4e00\u4e2a\u8fd8\u539f\u8fc7\u7684\u63d0\u4ea4\uff0c\u4ee5\u4fbf\u80fd\u591f\u660e\u786e\u5730\u77e5\u9053\u8be5\u4e8b\u9879\u7684\u8fdb\u884c\u60c5\u51b5\u3002<\/p>\n<h3>\u64a4\u9500\u7279\u5b9a\u7684\u63d0\u4ea4<\/h3>\n<p>\u4e5f\u53ef\u4ee5\u901a\u8fc7\u6307\u5b9a\u7279\u5b9a\u7684\u54c8\u5e0c\u503c\u8fdb\u884c\u8fd8\u539f\u3002\u4f46\u662f\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u88ab\u8fd8\u539f\u7684\u6587\u4ef6\u4e0d\u4ec5\u4ec5\u662f\u7279\u5b9a\u63d0\u4ea4\u7684\u66f4\u6539\u88ab\u64a4\u9500\u4e86\uff0c\u800c\u662f\u5b8c\u5168\u56de\u5230\u4e86\u90a3\u4e2a\u65f6\u95f4\u70b9\u7684\u72b6\u6001\u3002<\/p>\n<p>\u53e6\u5916\uff0c\u901a\u8fc7\u8fd8\u539f\u64cd\u4f5c\u6240\u63d0\u4ea4\u7684\u63d0\u4ea4\u5c06\u53ea\u5305\u62ec\u201c\u6307\u5b9a\u7684\u63d0\u4ea4\u201d\u3002<\/p>\n<p>\u6211\u4f1a\u5728\u5df2\u521b\u5efa\u7684README\u6587\u4ef6\u4e2d\u6dfb\u52a0D\u3001E\u548cF\u6807\u9898\uff0c\u5e76\u68c0\u67e5\u4e0b\u4e00\u4e2a\u72b6\u6001\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"gu\">## A<\/span>\r\nA\r\nA\r\n\r\n<span class=\"gu\">## E<\/span>\r\nE\r\nE\r\n\r\n<span class=\"gu\">## F<\/span>\r\nF\r\nF\r\n\r\n<span class=\"gu\">## D<\/span>\r\nD\r\nD\r\n\r\n<span class=\"gu\">## B<\/span>\r\nB\r\nB\r\n\r\n<span class=\"gu\">## C<\/span>\r\nC\r\nC\r\n\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d2d1937434c4406c5033a\/61-0.png\" alt=\"image.png\" \/><\/div>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span>git revert <span class=\"nt\">--no-edit<\/span> 11acd6f\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d2d1937434c4406c5033a\/63-1.png\" alt=\"image.png\" \/><\/div>\n<p>\u786e\u8ba4\u4ece\u6807\u9898B\u5230\u6807\u9898F\u7684\u6240\u6709\u5185\u5bb9\u90fd\u5df2\u88ab\u53d6\u6d88\u3002\u5b83\u4f3c\u4e4e\u4e0e\u6307\u5b9a\u8303\u56f4\u76f8\u540c\uff0c\u4f46\u7531\u4e8e\u53ea\u6709\u4e00\u4e2a\u63d0\u4ea4\u8bb0\u5f55\uff0c\u5982\u679c\u60f3\u8981\u660e\u786e\u5730\u4fdd\u7559\u64a4\u9500\u5386\u53f2\uff0c\u53ef\u80fd\u9700\u8981\u6307\u5b9a\u8303\u56f4\u3002<\/p>\n<h2>\u6700\u540e<\/h2>\n<p>\u5728\u5c1d\u8bd5\u4e4b\u524d\uff0c\u6211\u8ba4\u4e3a\u64a4\u9500\u7279\u5b9a\u63d0\u4ea4\u53ea\u4f1a\u64a4\u9500\u201c\u7279\u5b9a\u5de5\u4f5c\u5185\u5bb9\u201d\uff0c\u4f46\u540e\u6765\u53d1\u73b0\u5e76\u4e0d\u662f\u8fd9\u6837\u3002<\/p>\n<p>\u6211\u8ba4\u4e3a\u901a\u8fc7\u8fd9\u6b21\u5b66\u4e60\uff0c\u6211\u4eec\u5e94\u8be5\u80fd\u591f\u76f8\u5f53\u7a0b\u5ea6\u5730\u51cf\u5c11\u201c\u505a\u7cdf\u7cd5\u4e86orz\u201d\u7684\u9891\u7387\u3002\u5e78\u8fd0\u7684\u662f\uff0c\u4e8b\u60c5\u8fd8\u6ca1\u6709\u51fa\u73b0\uff0c\u56e0\u6b64\u5373\u4f7f\u53d1\u751f\u4e86\u4ec0\u4e48\u4e8b\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u51b7\u9759\u5730\u5904\u7406\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9996\u5148 \u8fd9\u662f\u8239\u4e95\u603b\u7814\u6570\u5b57\u90e8\u95e8\u7684OSW\u3002\u7531\u4e8e\u9700\u6c42\u6682\u6401\uff0c\u6211\u8fdb\u884c\u4e86\u6839\u636e\u6211\u4eec\u4e1a\u52a1\u4f7f\u7528\u7684\u8fdc\u7a0b\u4ee3\u7801\u5e93\u7684\u4e00\u4e2a\u5206\u652f\u8fdb\u884c\u8fd8\u539f\u7684\u64cd\u4f5c [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-37208","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>git reset\u548cgit revert\u7684\u533a\u522b\u662f\u4ec0\u4e48\uff1f - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/git-reset\u548cgit-revert\u7684\u533a\u522b\u662f\u4ec0\u4e48\uff1f\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"git reset\u548cgit revert\u7684\u533a\u522b\u662f\u4ec0\u4e48\uff1f\" \/>\n<meta property=\"og:description\" content=\"\u9996\u5148 \u8fd9\u662f\u8239\u4e95\u603b\u7814\u6570\u5b57\u90e8\u95e8\u7684OSW\u3002\u7531\u4e8e\u9700\u6c42\u6682\u6401\uff0c\u6211\u8fdb\u884c\u4e86\u6839\u636e\u6211\u4eec\u4e1a\u52a1\u4f7f\u7528\u7684\u8fdc\u7a0b\u4ee3\u7801\u5e93\u7684\u4e00\u4e2a\u5206\u652f\u8fdb\u884c\u8fd8\u539f\u7684\u64cd\u4f5c [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/git-reset\u548cgit-revert\u7684\u533a\u522b\u662f\u4ec0\u4e48\uff1f\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2022-12-19T03:51:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-29T20:03:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d2d1937434c4406c5033a\/16-0.png\" \/>\n<meta name=\"author\" content=\"\u6e05, \u626c\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u6e05, \u626c\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/git-reset%e5%92%8cgit-revert%e7%9a%84%e5%8c%ba%e5%88%ab%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/git-reset%e5%92%8cgit-revert%e7%9a%84%e5%8c%ba%e5%88%ab%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f\/\",\"name\":\"git reset\u548cgit revert\u7684\u533a\u522b\u662f\u4ec0\u4e48\uff1f - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2022-12-19T03:51:38+00:00\",\"dateModified\":\"2024-04-29T20:03:29+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/cb5556d2501da73d864cac945e8d9461\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/git-reset%e5%92%8cgit-revert%e7%9a%84%e5%8c%ba%e5%88%ab%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/git-reset%e5%92%8cgit-revert%e7%9a%84%e5%8c%ba%e5%88%ab%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/git-reset%e5%92%8cgit-revert%e7%9a%84%e5%8c%ba%e5%88%ab%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"git reset\u548cgit revert\u7684\u533a\u522b\u662f\u4ec0\u4e48\uff1f\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/cb5556d2501da73d864cac945e8d9461\",\"name\":\"\u6e05, \u626c\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/32a4239de8ff29adace466261d309424a1e5fe9f7e3036bf89fe03f2e3dbe717?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/32a4239de8ff29adace466261d309424a1e5fe9f7e3036bf89fe03f2e3dbe717?s=96&d=mm&r=g\",\"caption\":\"\u6e05, \u626c\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyang\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/git-reset%e5%92%8cgit-revert%e7%9a%84%e5%8c%ba%e5%88%ab%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"git reset\u548cgit revert\u7684\u533a\u522b\u662f\u4ec0\u4e48\uff1f - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/git-reset\u548cgit-revert\u7684\u533a\u522b\u662f\u4ec0\u4e48\uff1f\/","og_locale":"zh_CN","og_type":"article","og_title":"git reset\u548cgit revert\u7684\u533a\u522b\u662f\u4ec0\u4e48\uff1f","og_description":"\u9996\u5148 \u8fd9\u662f\u8239\u4e95\u603b\u7814\u6570\u5b57\u90e8\u95e8\u7684OSW\u3002\u7531\u4e8e\u9700\u6c42\u6682\u6401\uff0c\u6211\u8fdb\u884c\u4e86\u6839\u636e\u6211\u4eec\u4e1a\u52a1\u4f7f\u7528\u7684\u8fdc\u7a0b\u4ee3\u7801\u5e93\u7684\u4e00\u4e2a\u5206\u652f\u8fdb\u884c\u8fd8\u539f\u7684\u64cd\u4f5c [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/git-reset\u548cgit-revert\u7684\u533a\u522b\u662f\u4ec0\u4e48\uff1f\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2022-12-19T03:51:38+00:00","article_modified_time":"2024-04-29T20:03:29+00:00","og_image":[{"url":"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d2d1937434c4406c5033a\/16-0.png"}],"author":"\u6e05, \u626c","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u6e05, \u626c","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/git-reset%e5%92%8cgit-revert%e7%9a%84%e5%8c%ba%e5%88%ab%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/git-reset%e5%92%8cgit-revert%e7%9a%84%e5%8c%ba%e5%88%ab%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f\/","name":"git reset\u548cgit revert\u7684\u533a\u522b\u662f\u4ec0\u4e48\uff1f - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2022-12-19T03:51:38+00:00","dateModified":"2024-04-29T20:03:29+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/cb5556d2501da73d864cac945e8d9461"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/git-reset%e5%92%8cgit-revert%e7%9a%84%e5%8c%ba%e5%88%ab%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/git-reset%e5%92%8cgit-revert%e7%9a%84%e5%8c%ba%e5%88%ab%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/git-reset%e5%92%8cgit-revert%e7%9a%84%e5%8c%ba%e5%88%ab%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"git reset\u548cgit revert\u7684\u533a\u522b\u662f\u4ec0\u4e48\uff1f"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/cb5556d2501da73d864cac945e8d9461","name":"\u6e05, \u626c","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/32a4239de8ff29adace466261d309424a1e5fe9f7e3036bf89fe03f2e3dbe717?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/32a4239de8ff29adace466261d309424a1e5fe9f7e3036bf89fe03f2e3dbe717?s=96&d=mm&r=g","caption":"\u6e05, \u626c"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyang\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/git-reset%e5%92%8cgit-revert%e7%9a%84%e5%8c%ba%e5%88%ab%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/37208","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=37208"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/37208\/revisions"}],"predecessor-version":[{"id":89567,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/37208\/revisions\/89567"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=37208"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=37208"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=37208"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}