{"id":29120,"date":"2023-09-13T13:51:52","date_gmt":"2023-09-13T05:51:52","guid":{"rendered":"http:\/\/gulass.cn\/?p=29120"},"modified":"2023-09-13T13:51:52","modified_gmt":"2023-09-13T05:51:52","slug":"how-git-backspace","status":"publish","type":"post","link":"https:\/\/gulass.cn\/how-git-backspace.html","title":{"rendered":"Git \u7cfb\u5217\uff08\u56db\uff09\uff1a\u5982\u4f55\u5728 Git \u4e2d\u8fdb\u884c\u7248\u672c\u56de\u9000"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u4f60\u5c06\u5b66\u5230\u5982\u4f55\u67e5\u770b\u9879\u76ee\u4e2d\u7684\u5386\u53f2\u7248\u672c\uff0c\u5982\u4f55\u8fdb\u884c\u7248\u672c\u56de\u9000\uff0c\u4ee5\u53ca\u5982\u4f55\u521b\u5efa Git \u5206\u652f\u4ee5\u4fbf\u4f60\u53ef\u4ee5\u5927\u80c6\u5c1d\u8bd5\u800c\u4e0d\u4f1a\u51fa\u73b0\u95ee\u9898\u3002\u5728\u4f60\u7684 Git \u9879\u76ee\u7684\u5386\u53f2\u4e2d\uff0c\u4f60\u7684\u4f4d\u7f6e\u5c31\u50cf\u662f\u6447\u6eda\u4e13\u8f91\u4e2d\u7684\u4e00\u4e2a\u7247\u6bb5\uff0c\u7531\u4e00\u4e2a\u88ab\u79f0\u4e3a HEAD \u7684 \u6807\u8bb0\u6765\u786e\u5b9a\u3002\u8981\u5728\u4f60\u7684 Git \u65f6\u95f4\u7ebf\u4e0a\u524d\u540e\u79fb\u52a8 HEAD \uff0c\u9700\u8981\u4f7f\u7528 git checkout \u547d\u4ee4\u3002git checkout \u547d\u4ee4\u7684\u4f7f\u7528\u65b9\u5f0f\u6709\u4e24\u79cd\u3002\u6700\u5e38\u89c1\u7684\u7528\u9014\u662f\u4ece\u4e00\u4e2a\u4ee5\u524d\u7684\u63d0\u4ea4\u4e2d\u6062\u590d\u6587\u4ef6\uff0c\u4f60\u4e5f\u53ef\u4ee5\u6574\u4e2a\u5012\u56de\u78c1\u5e26\uff0c\u5207\u6362\u5230\u53e6\u4e00\u4e2a\u5206\u652f\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

<\/h2>\n

\"Git<\/p>\n

\u6062\u590d\u4e00\u4e2a\u6587\u4ef6<\/strong><\/span><\/div>\n

\u5f53\u4f60\u610f\u8bc6\u5230\u4e00\u4e2a\u672c\u6765\u5f88\u597d\u6587\u4ef6\u88ab\u4f60\u5b8c\u5168\u6539\u4e71\u4e86\u3002\u6211\u4eec\u90fd\u8fd9\u4e48\u5e72\u8fc7\uff1a\u6211\u4eec\u628a\u6587\u4ef6\u653e\u5230\u4e00\u4e2a\u5730\u65b9\uff0c\u6dfb\u52a0\u5e76\u63d0\u4ea4\uff0c\u7136\u540e\u6211\u4eec\u53d1\u73b0\u5b83\u8fd8\u9700\u8981\u505a\u70b9\u6700\u540e\u7684\u8c03\u6574\uff0c\u6700\u540e\u8fd9\u4e2a\u6587\u4ef6\u88ab\u641e\u5f97\u9762\u76ee\u5168\u975e\u4e86\u3002
\n\u8981\u628a\u5b83\u6062\u590d\u5230\u6700\u540e\u7684\u5b8c\u597d\u72b6\u6001\uff0c\u4f7f\u7528 git checkout \u4ece\u6700\u540e\u7684\u63d0\u4ea4(\u5373 HEAD)\u4e2d\u6062\u590d\uff1a<\/p>\n

 $\u00a0git\u00a0checkout\u00a0HEAD\u00a0filename\r\n<\/pre>\n

\u5982\u679c\u4f60\u78b0\u5de7\u63d0\u4ea4\u4e86\u4e00\u4e2a\u9519\u8bef\u7684\u7248\u672c\uff0c\u4f60\u9700\u8981\u627e\u56de\u66f4\u65e9\u7684\u7248\u672c\uff0c\u4f7f\u7528 git log \u67e5\u770b\u4f60\u66f4\u65e9\u7684\u63d0\u4ea4\uff0c\u7136\u540e\u4ece\u5408\u9002\u7684\u63d0\u4ea4\u4e2d\u627e\u56de\u5b83\uff1a<\/p>\n

$\u00a0git\u00a0log\u00a0--oneline\r\n79a4e5f\u00a0bad\u00a0take\r\nf449007\u00a0The\u00a0second\u00a0commit\r\n55df4c2\u00a0My\u00a0great\u00a0project,\u00a0first\u00a0commit.\r\n$\u00a0git\u00a0checkout\u00a055df4c2\u00a0filename\r\n<\/pre>\n

\u73b0\u5728\uff0c\u4ee5\u524d\u7684\u6587\u4ef6\u6062\u590d\u5230\u4e86\u4f60\u5f53\u524d\u7684\u4f4d\u7f6e\u3002(\u4efb\u4f55\u65f6\u5019\u4f60\u90fd\u53ef\u4ee5\u7528 git status \u547d\u4ee4\u67e5\u770b\u4f60\u7684\u5f53\u524d\u72b6\u6001)\u56e0\u4e3a\u8fd9\u4e2a\u6587\u4ef6\u6539\u53d8\u4e86\uff0c\u4f60\u9700\u8981\u6dfb\u52a0\u8fd9\u4e2a\u6587\u4ef6\uff0c\u518d\u8fdb\u884c\u63d0\u4ea4\uff1a<\/p>\n

$\u00a0git\u00a0add\u00a0filename\r\n$\u00a0git\u00a0commit\u00a0-m\u00a0'restoring\u00a0filename\u00a0from\u00a0first\u00a0commit.'\r\n<\/pre>\n

\u4f7f\u7528 git log \u9a8c\u8bc1\u4f60\u6240\u63d0\u4ea4\u7684\uff1a<\/p>\n

$\u00a0git\u00a0log\u00a0--oneline\r\nd512580\u00a0restoring\u00a0filename\u00a0from\u00a0first\u00a0commit\r\n79a4e5f\u00a0bad\u00a0take\r\nf449007\u00a0The\u00a0second\u00a0commit\r\n55df4c2\u00a0My\u00a0great\u00a0project,\u00a0first\u00a0commit.\r\n<\/pre>\n

\u4ece\u672c\u8d28\u4e0a\u8bb2\uff0c\u4f60\u5df2\u7ecf\u5012\u597d\u4e86\u78c1\u5e26\u5e76\u4fee\u590d\u4e86\u574f\u7684\u5730\u65b9\uff0c\u6240\u4ee5\u4f60\u9700\u8981\u91cd\u65b0\u5f55\u5236\u6b63\u786e\u7684\u3002<\/p>\n

\u56de\u9000\u65f6\u95f4\u7ebf<\/strong><\/span><\/div>\n

\u6062\u590d\u6587\u4ef6\u7684\u53e6\u4e00\u79cd\u65b9\u5f0f\u662f\u56de\u9000\u6574\u4e2a Git \u9879\u76ee\u3002\u8fd9\u91cc\u4f7f\u7528\u4e86\u5206\u652f\u7684\u601d\u60f3\uff0c\u8fd9\u662f\u53e6\u4e00\u79cd\u66ff\u4ee3\u65b9\u6cd5\u3002
\n\u5982\u679c\u4f60\u8981\u56de\u5230\u5386\u53f2\u63d0\u4ea4\uff0c\u4f60\u8981\u5c06 Git HEAD \u56de\u9000\u5230\u4ee5\u524d\u7684\u7248\u672c\u624d\u884c\u3002\u8fd9\u4e2a\u4f8b\u5b50\u5c06\u56de\u5230\u6700\u521d\u7684\u63d0\u4ea4\u5904\uff1a<\/p>\n

$\u00a0git\u00a0log\u00a0--oneline\r\nd512580\u00a0restoring\u00a0filename\u00a0from\u00a0first\u00a0commit\r\n79a4e5f\u00a0bad\u00a0take\r\nf449007\u00a0The\u00a0second\u00a0commit\r\n55df4c2\u00a0My\u00a0great\u00a0project,\u00a0first\u00a0commit.\r\n$\u00a0git\u00a0checkout\u00a055df4c2\r\n<\/pre>\n

\u5f53\u4f60\u4ee5\u8fd9\u79cd\u65b9\u5f0f\u5012\u56de\u78c1\u5e26\uff0c\u5982\u679c\u4f60\u6309\u4e0b\u5f55\u97f3\u952e\u518d\u6b21\u5f00\u59cb\uff0c\u5c31\u4f1a\u4e22\u5931\u4ee5\u524d\u7684\u5de5\u4f5c\u3002Git \u9ed8\u8ba4\u5047\u5b9a\u4f60\u4e0d\u60f3\u8fd9\u6837\u505a\uff0c\u6240\u4ee5\u5c06 HEAD \u4ece\u9879\u76ee\u4e2d\u5206\u79bb\u51fa\u6765\uff0c\u53ef\u4ee5\u8ba9\u4f60\u5982\u6240\u9700\u7684\u90a3\u6837\u5de5\u4f5c\uff0c\u800c\u4e0d\u4f1a\u56e0\u4e3a\u5076\u5c14\u7684\u8bb0\u5f55\u800c\u5f71\u54cd\u4e4b\u540e\u7684\u5de5\u4f5c\u3002
\n\u5982\u679c\u4f60\u60f3\u770b\u770b\u4ee5\u524d\u7684\u7248\u672c\uff0c\u60f3\u8981\u91cd\u65b0\u505a\u6216\u8005\u5c1d\u8bd5\u4e0d\u540c\u7684\u65b9\u6cd5\uff0c\u90a3\u4e48\u5b89\u5168\u4e00\u70b9\u7684\u65b9\u5f0f\u5c31\u662f\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5206\u652f\u3002\u53ef\u4ee5\u5c06\u8fd9\u4e2a\u8fc7\u7a0b\u60f3\u8c61\u4e3a\u5c1d\u8bd5\u540c\u4e00\u9996\u6b4c\u66f2\u7684\u4e0d\u540c\u7248\u672c\uff0c\u6216\u8005\u521b\u5efa\u4e00\u4e2a\u6df7\u97f3\u7684\u3002\u539f\u59cb\u7684\u4f9d\u7136\u5b58\u5728\uff0c\u5173\u95ed\u90a3\u4e2a\u5206\u652f\u505a\u4f60\u60f3\u505a\u7684\u7248\u672c\u5427\u3002
\n\u5c31\u50cf\u8bb0\u5f55\u5230\u4e00\u4e2a\u7a7a\u767d\u78c1\u5e26\u4e00\u6837\uff0c\u628a\u4f60\u7684 Git HEAD \u6307\u5230\u4e00\u4e2a\u65b0\u7684\u5206\u652f\u5904\uff1a<\/p>\n

$\u00a0git\u00a0checkout\u00a0-b\u00a0remix\r\nSwitched\u00a0to\u00a0a\u00a0new\u00a0branch\u00a0'remix'\r\n<\/pre>\n

\u73b0\u5728\u4f60\u5df2\u7ecf\u5207\u6362\u5230\u4e86\u53e6\u4e00\u4e2a\u5206\u652f\uff0c\u5728\u4f60\u9762\u524d\u7684\u662f\u4e00\u4e2a\u66ff\u4ee3\u7684\u5e72\u51c0\u5de5\u4f5c\u533a\uff0c\u51c6\u5907\u5f00\u59cb\u5de5\u4f5c\u5427\u3002
\n\u4e5f\u53ef\u4ee5\u4e0d\u7528\u6539\u53d8\u65f6\u95f4\u7ebf\u6765\u505a\u540c\u6837\u7684\u4e8b\u60c5\u3002\u4e5f\u8bb8\u4f60\u5f88\u60f3\u8fd9\u4e48\u505a\uff0c\u4f46\u5207\u6362\u5230\u4e00\u4e2a\u4e34\u65f6\u7684\u5de5\u4f5c\u533a\u53ea\u662f\u4e3a\u4e86\u5c1d\u8bd5\u4e00\u4e9b\u75af\u72c2\u7684\u60f3\u6cd5\u3002\u8fd9\u5728\u5de5\u4f5c\u4e2d\u5b8c\u5168\u662f\u53ef\u4ee5\u63a5\u53d7\u7684\uff0c\u8bf7\u770b\uff1a<\/p>\n

$\u00a0git\u00a0status\r\nOn\u00a0branch\u00a0master\r\nnothing\u00a0to\u00a0commit,\u00a0working\u00a0directory\u00a0clean\r\n$\u00a0git\u00a0checkout\u00a0-b\u00a0crazy_idea\r\nSwitched\u00a0to\u00a0a\u00a0new\u00a0branch\u00a0'crazy_idea'\r\n<\/pre>\n

\u73b0\u5728\u4f60\u6709\u4e00\u4e2a\u5e72\u51c0\u7684\u5de5\u4f5c\u7a7a\u95f4\uff0c\u5728\u8fd9\u91cc\u4f60\u53ef\u4ee5\u5b8c\u6210\u4e00\u4e9b\u5947\u602a\u7684\u60f3\u6cd5\u3002\u4e00\u65e6\u4f60\u5b8c\u6210\u4e86\uff0c\u53ef\u4ee5\u4fdd\u7559\u4f60\u7684\u6539\u53d8\uff0c\u6216\u8005\u4e22\u5f03\u4ed6\u4eec\uff0c\u5e76\u5207\u6362\u56de\u4f60\u7684\u4e3b\u5206\u652f\u3002
\n\u82e5\u8981\u653e\u5f03\u4f60\u7684\u60f3\u6cd5\uff0c\u5207\u6362\u5230\u4f60\u7684\u4e3b\u5206\u652f\uff0c\u5047\u88c5\u65b0\u5206\u652f\u4e0d\u5b58\u5728\uff1a<\/p>\n

$\u00a0git\u00a0checkout\u00a0master\r\n<\/pre>\n

\u60f3\u8981\u7ee7\u7eed\u4f7f\u7528\u4f60\u7684\u75af\u72c2\u7684\u60f3\u6cd5\uff0c\u9700\u8981\u628a\u5b83\u4eec\u62c9\u56de\u5230\u4e3b\u5206\u652f\uff0c\u5207\u6362\u5230\u4e3b\u5206\u652f\u7136\u540e\u5408\u5e76\u65b0\u5206\u652f\u5230\u4e3b\u5206\u652f\uff1a<\/p>\n

$\u00a0git\u00a0checkout\u00a0master\r\n$\u00a0git\u00a0merge\u00a0crazy_idea\r\n<\/pre>\n

git \u7684\u5206\u652f\u529f\u80fd\u5f88\u5f3a\u5927\uff0c\u5f00\u53d1\u4eba\u5458\u5728\u514b\u9686\u4ed3\u5e93\u540e\u9a6c\u4e0a\u521b\u5efa\u4e00\u4e2a\u65b0\u5206\u652f\u662f\u5f88\u5e38\u89c1\u7684\u505a\u6cd5;\u8fd9\u6837\uff0c\u4ed6\u4eec\u6240\u6709\u7684\u5de5\u4f5c\u90fd\u5728\u81ea\u5df1\u7684\u5206\u652f\u4e0a\uff0c\u53ef\u4ee5\u63d0\u4ea4\u5e76\u5408\u5e76\u5230\u4e3b\u5206\u652f\u3002Git \u662f\u5f88\u7075\u6d3b\u7684\uff0c\u6240\u4ee5\u6ca1\u6709\u201c\u6b63\u786e\u201d\u6216\u201c\u9519\u8bef\u201d\u7684\u65b9\u5f0f(\u751a\u81f3\u4e00\u4e2a\u4e3b\u5206\u652f\u4e5f\u53ef\u4ee5\u4e0e\u5176\u6240\u5c5e\u7684\u8fdc\u7a0b\u4ed3\u5e93\u5206\u79bb)\uff0c\u4f46\u5206\u652f\u6613\u4e8e\u5206\u79bb\u4efb\u52a1\u548c\u63d0\u4ea4\u8d21\u732e\u3002\u4e0d\u8981\u592a\u6fc0\u52a8\uff0c\u4f60\u53ef\u4ee5\u5982\u4f60\u6240\u613f\u7684\u6709\u5f88\u591a\u7684 Git \u5206\u652f\u3002\u5b8c\u5168\u81ea\u7531\u3002<\/p>\n

\u8fdc\u7a0b\u534f\u4f5c<\/strong><\/span><\/div>\n

\u5230\u76ee\u524d\u4e3a\u6b62\u4f60\u5df2\u7ecf\u5728\u81ea\u5df1\u8212\u9002\u800c\u79c1\u5bc6\u7684\u5bb6\u4e2d\u7ef4\u62a4\u7740\u4e00\u4e2a Git \u4ed3\u5e93\uff0c\u4f46\u5982\u4f55\u4e0e\u5176\u4ed6\u4eba\u534f\u540c\u5de5\u4f5c\u5462?
\n\u6709\u597d\u51e0\u79cd\u4e0d\u540c\u7684\u65b9\u5f0f\u6765\u8bbe\u7f6e Git \u4ee5\u4fbf\u8ba9\u591a\u4eba\u53ef\u4ee5\u540c\u65f6\u5728\u4e00\u4e2a\u9879\u76ee\u4e0a\u5de5\u4f5c\uff0c\u6240\u4ee5\u9996\u5148\u6211\u4eec\u8981\u514b\u9686\u4ed3\u5e93\uff0c\u4f60\u53ef\u80fd\u5df2\u7ecf\u4ece\u67d0\u4eba\u7684 Git \u670d\u52a1\u5668\u6216 GitHub \u4e3b\u9875\uff0c\u6216\u5728\u5c40\u57df\u7f51\u4e2d\u7684\u5171\u4eab\u5b58\u50a8\u4e0a\u514b\u9686\u4e86\u4e00\u4e2a\u4ed3\u5e93\u3002
\n\u5de5\u4f5c\u5728\u79c1\u4eba\u4ed3\u5e93\u4e0b\u548c\u5171\u4eab\u4ed3\u5e93\u4e0b\u552f\u4e00\u4e0d\u540c\u7684\u662f\u4f60\u9700\u8981\u628a\u4f60\u7684\u6539\u53d8 push \u5230\u522b\u4eba\u7684\u4ed3\u5e93\u3002\u6211\u4eec\u628a\u5de5\u4f5c\u7684\u4ed3\u5e93\u79f0\u4e4b\u4e3a\u672c\u5730(local)\u4ed3\u5e93\uff0c\u5176\u4ed6\u4ed3\u5e93\u79f0\u4e3a\u8fdc\u7a0b(remote)\u4ed3\u5e93\u3002
\n\u5f53\u4f60\u4ee5\u8bfb\u5199\u7684\u65b9\u5f0f\u514b\u9686\u4e00\u4e2a\u4ed3\u5e93\u65f6\uff0c\u514b\u9686\u7684\u4ed3\u5e93\u4f1a\u7ee7\u627f\u81ea\u88ab\u79f0\u4e3a origin \u7684\u8fdc\u7a0b\u5e93\u3002\u4f60\u53ef\u4ee5\u770b\u770b\u4f60\u7684\u514b\u9686\u4ed3\u5e93\u7684\u8fdc\u7a0b\u4ed3\u5e93\uff1a<\/p>\n

$\u00a0git\u00a0remote\u00a0--verbose\r\norigin\u00a0\u00a0seth@example.com:~\/myproject.Git\u00a0(fetch)\r\norigin\u00a0\u00a0seth@example.com:~\/myproject.Git\u00a0(push)\r\n<\/pre>\n

\u6709\u4e00\u4e2a origin \u8fdc\u7a0b\u5e93\u975e\u5e38\u6709\u7528\uff0c\u56e0\u4e3a\u5b83\u6709\u5f02\u5730\u5907\u4efd\u7684\u529f\u80fd\uff0c\u5e76\u5141\u8bb8\u5176\u4ed6\u4eba\u5728\u8be5\u9879\u76ee\u4e0a\u5de5\u4f5c\u3002
\n\u5982\u679c\u514b\u9686\u6ca1\u6709\u7ee7\u627f origin \u8fdc\u7a0b\u5e93\uff0c\u6216\u8005\u5982\u679c\u4f60\u9009\u62e9\u4ee5\u540e\u518d\u6dfb\u52a0\uff0c\u53ef\u4ee5\u4f7f\u7528 git remote \u547d\u4ee4\uff1a<\/p>\n

$\u00a0git\u00a0remote\u00a0add\u00a0seth@example.com:~\/myproject.Git\r\n<\/pre>\n

\u5982\u679c\u4f60\u4fee\u6539\u4e86\u6587\u4ef6\uff0c\u60f3\u628a\u5b83\u4eec\u53d1\u5230\u6709\u8bfb\u5199\u6743\u9650\u7684 origin \u8fdc\u7a0b\u5e93\uff0c\u4f7f\u7528 git push\u3002\u7b2c\u4e00\u6b21\u63a8\u9001\u6539\u53d8\uff0c\u5fc5\u987b\u4e5f\u53d1\u9001\u5206\u652f\u4fe1\u606f\u3002\u4e0d\u76f4\u63a5\u5728\u4e3b\u5206\u652f\u4e0a\u5de5\u4f5c\u662f\u4e00\u4e2a\u5f88\u597d\u7684\u505a\u6cd5\uff0c\u9664\u975e\u4f60\u88ab\u8981\u6c42\u8fd9\u6837\u505a\uff1a<\/p>\n

$\u00a0git\u00a0checkout\u00a0-b\u00a0seth-dev\r\n$\u00a0git\u00a0add\u00a0exciting-new-file.txt\r\n$\u00a0git\u00a0commit\u00a0-m\u00a0'first\u00a0push\u00a0to\u00a0remote'\r\n$\u00a0git\u00a0push\u00a0-u\u00a0origin\u00a0HEAD\r\n<\/pre>\n

\u5b83\u4f1a\u63a8\u9001\u4f60\u5f53\u524d\u7684\u4f4d\u7f6e(HEAD)\u53ca\u5176\u5b58\u5728\u7684\u5206\u652f\u5230\u8fdc\u7a0b\u3002\u5f53\u63a8\u9001\u8fc7\u4e00\u6b21\u540e\uff0c\u4ee5\u540e\u6bcf\u6b21\u63a8\u9001\u53ef\u4ee5\u4e0d\u4f7f\u7528 -u \u9009\u9879\uff1a<\/p>\n

$\u00a0git\u00a0add\u00a0another-file.txt\r\n$\u00a0git\u00a0commit\u00a0-m\u00a0'another\u00a0push\u00a0to\u00a0remote'\r\n$\u00a0git\u00a0push\u00a0origin\u00a0HEAD\r\n<\/pre>\n
\u5408\u5e76\u5206\u652f<\/strong><\/span><\/div>\n

\u5f53\u4f60\u5de5\u4f5c\u5728\u4e00\u4e2a Git \u4ed3\u5e93\u65f6\uff0c\u4f60\u53ef\u4ee5\u5408\u5e76\u4efb\u610f\u6d4b\u8bd5\u5206\u652f\u5230\u4e3b\u5206\u652f\u3002\u5f53\u56e2\u961f\u534f\u4f5c\u65f6\uff0c\u4f60\u53ef\u80fd\u60f3\u5728\u5c06\u5b83\u4eec\u5408\u5e76\u5230\u4e3b\u5206\u652f\u4e4b\u524d\u68c0\u67e5\u4ed6\u4eec\u7684\u6539\u53d8\uff1a<\/p>\n

$\u00a0git\u00a0checkout\u00a0contributor\r\n$\u00a0git\u00a0pull\r\n$\u00a0less\u00a0blah.txt\u00a0\u00a0###\u00a0\u68c0\u67e5\u6539\u53d8\u7684\u6587\u4ef6\r\n$\u00a0git\u00a0checkout\u00a0master\r\n$\u00a0git\u00a0merge\u00a0contributor\r\n<\/pre>\n

\u5982\u679c\u4f60\u6b63\u5728\u4f7f\u7528 GitHub \u6216 GitLab \u4ee5\u53ca\u7c7b\u4f3c\u7684\u4e1c\u897f\uff0c\u8fd9\u4e2a\u8fc7\u7a0b\u662f\u4e0d\u540c\u7684\u3002\u4f46\u514b\u9686\u9879\u76ee\u5e76\u628a\u5b83\u4f5c\u4e3a\u4f60\u81ea\u5df1\u7684\u4ed3\u5e93\u90fd\u662f\u76f8\u4f3c\u7684\u3002\u4f60\u53ef\u4ee5\u5728\u672c\u5730\u5de5\u4f5c\uff0c\u5c06\u6539\u53d8\u63d0\u4ea4\u5230\u4f60\u7684 GitHub \u6216 GitLab \u5e10\u6237\uff0c\u800c\u4e0d\u7528\u5176\u5b83\u4eba\u7684\u8bb8\u53ef\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u5e93\u662f\u4f60\u81ea\u5df1\u7684\u3002
\n\u5982\u679c\u4f60\u60f3\u8981\u8ba9\u4f60\u514b\u9686\u7684\u4ed3\u5e93\u63a5\u53d7\u4f60\u7684\u6539\u53d8\uff0c\u9700\u8981\u521b\u5efa\u4e86\u4e00\u4e2a\u62c9\u53d6\u8bf7\u6c42(pull request)\uff0c\u5b83\u4f7f\u7528 Web \u670d\u52a1\u7684\u540e\u7aef\u53d1\u9001\u8865\u4e01\u5230\u771f\u6b63\u7684\u62e5\u6709\u8005\uff0c\u5e76\u5141\u8bb8\u4ed6\u4eec\u5ba1\u67e5\u548c\u62c9\u53d6\u4f60\u7684\u6539\u53d8\u3002
\n\u514b\u9686\u4e00\u4e2a\u9879\u76ee\u901a\u5e38\u662f\u5728 Web \u670d\u52a1\u7aef\u5b8c\u6210\u7684\uff0c\u5b83\u548c\u4f7f\u7528 Git \u547d\u4ee4\u6765\u7ba1\u7406\u9879\u76ee\u662f\u7c7b\u4f3c\u7684\uff0c\u751a\u81f3\u63a8\u9001\u7684\u8fc7\u7a0b\u4e5f\u662f\u3002\u7136\u540e\u5b83\u8fd4\u56de\u5230 Web \u670d\u52a1\u6253\u5f00\u4e00\u4e2a\u62c9\u53d6\u8bf7\u6c42\uff0c\u5de5\u4f5c\u5c31\u5b8c\u6210\u4e86\u3002
\n\u4e0b\u4e00\u90e8\u5206\u6211\u4eec\u5c06\u6574\u5408\u4e00\u4e9b\u6709\u7528\u7684\u63d2\u4ef6\u5230 Git \u4e2d\u6765\u5e2e\u4f60\u8f7b\u677e\u7684\u5b8c\u6210\u65e5\u5e38\u5de5\u4f5c\u3002<\/p>\n

\n

\u539f\u6587\u6765\u81ea\uff1ahttp:\/\/os.51cto.com\/art\/201608\/516259.htm<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1ahttp:\/\/gulass.cn\/how-git-backspace.html<\/a>\u7f16\u8f91\u5458\uff1a\u5218\u5cf0\uff0c\u5ba1\u6838\u5458\uff1a\u9004\u589e\u5b9d<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u4f60\u5c06\u5b66\u5230\u5982\u4f55\u67e5\u770b\u9879\u76ee\u4e2d\u7684\u5386\u53f2\u7248\u672c\uff0c\u5982\u4f55\u8fdb\u884c\u7248\u672c\u56de\u9000\uff0c\u4ee5\u53ca\u5982\u4f55\u521b\u5efa Git \u5206\u652f\u4ee5\u4fbf\u4f60\u53ef\u4ee5\u5927\u80c6\u5c1d\u8bd5\u800c\u4e0d\u4f1a\u51fa\u73b0\u95ee\u9898\u3002
\n\u5728\u4f60\u7684 Git \u9879\u76ee\u7684\u5386\u53f2\u4e2d\uff0c\u4f60\u7684\u4f4d\u7f6e\u5c31\u50cf\u662f\u6447\u6eda\u4e13\u8f91\u4e2d\u7684\u4e00\u4e2a\u7247\u6bb5\uff0c\u7531\u4e00\u4e2a\u88ab\u79f0\u4e3a HEAD \u7684 \u6807\u8bb0\u6765\u786e\u5b9a(\u5982\u78c1\u5e26\u5f55\u97f3\u673a\u6216\u5f55\u97f3\u64ad\u653e\u5668\u7684\u64ad\u653e\u5934)\u3002\u8981\u5728\u4f60\u7684 Git \u65f6\u95f4\u7ebf\u4e0a\u524d\u540e\u79fb\u52a8 HEAD \uff0c\u9700\u8981\u4f7f\u7528 git checkout \u547d\u4ee4\u3002
\ngit checkout \u547d\u4ee4\u7684\u4f7f\u7528\u65b9\u5f0f\u6709\u4e24\u79cd\u3002\u6700\u5e38\u89c1\u7684\u7528\u9014\u662f\u4ece\u4e00\u4e2a\u4ee5\u524d\u7684\u63d0\u4ea4\u4e2d\u6062\u590d\u6587\u4ef6\uff0c\u4f60\u4e5f\u53ef\u4ee5\u6574\u4e2a\u5012\u56de\u78c1\u5e26\uff0c\u5207\u6362\u5230\u53e6\u4e00\u4e2a\u5206\u652f\u3002<\/p>\n","protected":false},"author":116,"featured_media":28125,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-29120","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/29120","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/116"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=29120"}],"version-history":[{"count":14,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/29120\/revisions"}],"predecessor-version":[{"id":78349,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/29120\/revisions\/78349"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/28125"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=29120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=29120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=29120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}