{"id":18559,"date":"2024-11-19T20:02:24","date_gmt":"2024-11-19T12:02:24","guid":{"rendered":"https:\/\/fwq.ai\/blog\/?p=18559"},"modified":"2024-11-19T20:02:24","modified_gmt":"2024-11-19T12:02:24","slug":"git-%e6%95%99%e7%a8%8b%e6%96%b0%e6%89%8b%e5%85%a5%e9%97%a8%e7%ac%94%e8%ae%b0","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/18559\/","title":{"rendered":"Git \u6559\u7a0b\u65b0\u624b\u5165\u95e8\u7b14\u8bb0"},"content":{"rendered":"<p>\u770b\u4e86\u4e00\u4e9bGit\u7684\u6559\u7a0b\uff0c\u6709\u4e00\u4e9b\u6307\u4ee4\u8fd8\u662f\u8ba9\u4eba\u6026\u7136\u5fc3\u52a8\u7684\uff0c\u751f\u6015\u81ea\u5df1\u5fd8\u8bb0\u4e86\uff0c\u8fd9\u91cc\u505a\u4e00\u4e2a\u7b14\u8bb0\uff0c\u770b\u5230\u8fd9\u4e2a\u7b14\u8bb0\u80fd\u591f\u9a6c\u4e0a\u60f3\u8d77\u6765\u3002\u5982\u679c\u9700\u8981\u5bf9Git\u8be6\u7ec6\u4e86\u89e3\u7684\uff0c\u53ef\u4ee5\u53bb\u5b98\u65b9\u7f51\u7ad9\u67e5\u770b\uff0c\u8fd9\u91cc\u8d34\u51fa\u4e00\u4e2a\u5b98\u65b9\u4e2d\u6587\u7248\u7684\u7535\u5b50\u4e66\uff1ahttps:\/\/git-scm.com\/book\/zh\/v2<\/p>\n<p>&nbsp;<\/p>\n<p>\u5173\u4e8eGit \u7684\u5386\u53f2\u7531\u6765\uff0c\u4ee5\u53ca\u4e8e\u96c6\u4e2d\u5f0f\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff08\u5982svn\u3001cvs\uff09\u7684\u533a\u522b\uff0c\u4ee5\u53ca\u5b89\u88c5git\uff0c\u8fd9\u91cc\u5c31\u4e0d\u4ecb\u7ecd\u4e86\u3002\u8865\u5145\u4e0b\uff0c\u5386\u53f2\u7531\u6765\u5176\u5b9e\u5f88\u6709\u610f\u601d\uff0c\u5475\u5475!!<\/p>\n<h1>\u4e00\u3001\u521d\u59cb\u5316\u672c\u5730\u7248\u672c\u5e93<\/h1>\n<p>\u521d\u59cb\u5316\u4e00\u4e2aGit\u4ed3\u5e93\uff0c\u4f7f\u7528\u00a0<strong><code>git init\u00a0<\/code><\/strong>\u547d\u4ee4\u3002<\/p>\n<p>\u6dfb\u52a0\u6587\u4ef6\u5230Git\u4ed3\u5e93\uff0c\u5206\u4e24\u6b65\uff1a<\/p>\n<ol>\n<li>\u4f7f\u7528\u547d\u4ee4<strong><code>git add &lt;file&gt;<\/code><\/strong>\uff0c\u6ce8\u610f\uff0c\u53ef\u53cd\u590d\u591a\u6b21\u4f7f\u7528\uff0c\u6dfb\u52a0\u591a\u4e2a\u6587\u4ef6\uff1b\u4e5f\u53ef\u4ee5\u4f7f\u7528\u00a0<strong>git add *\u00a0<\/strong>\uff0c\u6dfb\u52a0\u6240\u6709\u6587\u4ef6\u3002<\/li>\n<li>\u4f7f\u7528\u547d\u4ee4<strong><code>git commit<\/code><\/strong>\uff0c\u5b8c\u6210\u3002\u6216\u8005\u4f7f\u7528\u00a0<strong>git commit -a<\/strong>\uff0c\u63d0\u4ea4\u6240\u6709\u6587\u4ef6\uff0c\u5305\u62ec\u672a git add \u7684\u6587\u4ef6\u3002<\/li>\n<\/ol>\n<h1>\u4e8c\u3001\u7248\u672c\u56de\u9000<\/h1>\n<ol>\n<li>\u4f7f\u7528\u00a0<strong>git log<\/strong>\u00a0\u67e5\u770b\u64cd\u4f5c\u8bb0\u5f55\uff0c\u5982\u679c\u65e5\u5fd7\u5185\u5bb9\u5f88\u591a\u53ef\u4ee5\u4f7f\u7528\u00a0<strong>git log \u2013pretty=oneline<\/strong><\/li>\n<li>\u4f7f\u7528<strong>git reflog<\/strong>\u67e5\u770bHEAD\u7684\u547d\u4ee4\u7684\u5386\u53f2\u8bb0\u5f55\u3002<\/li>\n<li>\u4f7f\u7528<strong>git reset HEAD<\/strong>\u00a0\u8fd4\u56de\u5230\u4e0a\u6b21\u63d0\u4ea4\uff0c<strong>git reset HEAD^^\u00a0<\/strong>\u8fd4\u56de\u5230\u4e0a2\u6b21\u7684\u63d0\u4ea4\u3002\u5982\u679c\u52a0\u4e0a\u53c2\u6570\u00a0<strong>&#8211; -hard<\/strong>\uff0c\u5219\u653e\u5f03\u5f53\u524d\u7684\u4fee\u6539\uff0c\u8fd9\u91cc\u4e0d\u5305\u62ec\u65b0\u589e\u6587\u4ef6\uff0c\u56e0\u4e3a\u65b0\u589e\u7684\u6587\u4ef6\u8fd8\u672a\u88abgit\u8ddf\u8e2a(<code>Untracked<\/code>).<\/li>\n<li>\u4f7f\u7528<strong>git reset<\/strong>\u00a0&lt;\u7248\u672c\u53f7&gt;\uff0c\u53ef\u4ee5\u4f7f\u7528<strong>git reflog<\/strong>\u5148\u67e5\u770b\u7248\u672c\u3002\u3002\u5982\u679c\u52a0\u4e0a\u53c2\u6570 \u2013 -hard\uff0c\u5219\u653e\u5f03\u5f53\u524d\u7684\u4fee\u6539\uff0c\u8fd9\u91cc\u4e0d\u5305\u62ec\u65b0\u589e\u6587\u4ef6\uff0c\u56e0\u4e3a\u65b0\u589e\u7684\u6587\u4ef6\u8fd8\u672a\u88abgit\u8ddf\u8e2a(<code>Untracked<\/code>)\u3002\u4f8b\u5982\uff1a<br \/>\ngit reset \u2013hard fb9e84b<\/li>\n<\/ol>\n<h1>\u4e09\u3001\u56de\u6eda<\/h1>\n<p class=\"p1\">git reset \u2013hard 5154589<br \/>\ngit fetch origin\/dev\u00a0<span class=\"s1\">\u548c<\/span>\u00a0git pull<br \/>\ngit reset origin\/dev<\/p>\n<h1>\u4e09\u3001\u7248\u672c\u64a4\u9500<\/h1>\n<ol>\n<li>\u5f53\u4f60\u6539\u4e71\u4e86\u5de5\u4f5c\u533a\u67d0\u4e2a\u6587\u4ef6\u7684\u5185\u5bb9\uff0c\u60f3\u76f4\u63a5\u4e22\u5f03\u5de5\u4f5c\u533a\u7684\u4fee\u6539\u65f6\uff0c\u7528\u547d\u4ee4<strong>git checkout \u2014 file<\/strong>\u3002<\/li>\n<li>\u5f53\u4f60\u4e0d\u4f46\u6539\u4e71\u4e86\u5de5\u4f5c\u533a\u67d0\u4e2a\u6587\u4ef6\u7684\u5185\u5bb9\uff0c\u8fd8\u6dfb\u52a0\u5230\u4e86\u6682\u5b58\u533a\u65f6\uff0c\u60f3\u4e22\u5f03\u4fee\u6539\uff0c\u5206\u4e24\u6b65\uff0c\u7b2c\u4e00\u6b65\u7528\u547d\u4ee4git reset HEAD file\uff0c\u5c31\u56de\u5230\u4e86\u573a\u666f1\uff0c\u7b2c\u4e8c\u6b65\u6309\u573a\u666f1\u64cd\u4f5c\u3002<\/li>\n<li>\u5df2\u7ecf\u63d0\u4ea4\u4e86\u4e0d\u5408\u9002\u7684\u4fee\u6539\u5230\u7248\u672c\u5e93\u65f6\uff0c\u60f3\u8981\u64a4\u9500\u672c\u6b21\u63d0\u4ea4\uff0c\u53c2\u8003\u7248\u672c\u56de\u9000\u4e00\u8282\uff0c\u4e0d\u8fc7\u524d\u63d0\u662f\u6ca1\u6709\u63a8\u9001\u5230\u8fdc\u7a0b\u5e93\u3002<\/li>\n<\/ol>\n<h1>\u56db\u3001\u5220\u9664\u6587\u4ef6<\/h1>\n<p>\u547d\u4ee4<code>git rm<\/code>\u7528\u4e8e\u5220\u9664\u4e00\u4e2a\u6587\u4ef6\u3002\u5982\u679c\u4e00\u4e2a\u6587\u4ef6\u5df2\u7ecf\u88ab\u63d0\u4ea4\u5230\u7248\u672c\u5e93\uff0c\u90a3\u4e48\u4f60\u6c38\u8fdc\u4e0d\u7528\u62c5\u5fc3\u8bef\u5220\uff0c\u4f46\u662f\u8981\u5c0f\u5fc3\uff0c\u4f60\u53ea\u80fd\u6062\u590d\u6587\u4ef6\u5230\u6700\u65b0\u7248\u672c\uff0c\u4f60\u4f1a\u4e22\u5931<strong>\u6700\u8fd1\u4e00\u6b21\u63d0\u4ea4\u540e\u4f60\u4fee\u6539\u7684\u5185\u5bb9<\/strong>\u3002<\/p>\n<h1>\u4e94\u3001\u5206\u652f\u7684\u521b\u5efa\u4e0e\u5408\u5e76<\/h1>\n<ol>\n<li>\u67e5\u770b\u5206\u652f\uff1a<code>git branch<\/code><\/li>\n<li>\u521b\u5efa\u5206\u652f\uff1a<code>git branch &lt;name&gt;<\/code><\/li>\n<li>\u5207\u6362\u5206\u652f\uff1a<code>git checkout &lt;name&gt;<\/code><\/li>\n<li>\u5408\u5e76\u67d0\u5206\u652f\u5230\u5f53\u524d\u5206\u652f\uff1a<code>git merge &lt;name&gt; ,\u4e5f\u4f7f\u7528 git merge --no-ff -m \"message\" &lt;branch&gt;\uff0c\u6ce8\u610f\u4e24\u6761\u547d\u4ee4\u7684\u533a\u522b\u3002\u52a0\u4e0a--no-ff\u53c2\u6570\u5c31\u53ef\u4ee5\u7528\u666e\u901a\u6a21\u5f0f\u5408\u5e76\uff0c\u5408\u5e76\u540e\u7684\u5386\u53f2\u6709\u5206\u652f\uff0c\u80fd\u770b\u51fa\u6765\u66fe\u7ecf\u505a\u8fc7\u5408\u5e76\uff0c\u800cfast forward\u5408\u5e76\u5c31\u770b\u4e0d\u51fa\u6765\u66fe\u7ecf\u505a\u8fc7\u5408\u5e76\u3002<br \/>\n<\/code><\/li>\n<li>\u5220\u9664\u5206\u652f\uff1a<code>git branch -d &lt;name&gt;\uff0c-D \u5f3a\u5236\u5220\u9664<br \/>\n<\/code><\/li>\n<li>\u5220\u9664\u8fdc\u7a0b\u5206\u652f\uff1agit branch -r -d origin\/fix0414<\/li>\n<\/ol>\n<h1>\u516d\u3001BUG\u5206\u652f<\/h1>\n<ol>\n<li>\u4fee\u590dbug\u65f6\uff0c\u6211\u4eec\u4f1a\u901a\u8fc7\u521b\u5efa\u65b0\u7684bug\u5206\u652f\u8fdb\u884c\u4fee\u590d\uff0c\u7136\u540e\u5408\u5e76\uff0c\u6700\u540e\u5220\u9664\uff1b<\/li>\n<li>\u5f53\u624b\u5934\u5de5\u4f5c\u6ca1\u6709\u5b8c\u6210\u65f6\uff0c\u5148\u628a\u5de5\u4f5c\u73b0\u573a<code>git stash<\/code>\u4e00\u4e0b\uff0c\u7136\u540e\u53bb\u4fee\u590dbug\uff0c\u4fee\u590d\u540e\uff0c\u518d<code>git stash pop<\/code>\uff0c\u56de\u5230\u5de5\u4f5c\u73b0\u573a\u3002<\/li>\n<li>\u76f8\u5173\u7684\u547d\u4ee4\u6709 stash list \u3001stash pop\u3001stash apply<code>\u3001stash drop\uff0c\u6ce8\u610fpop\u548capply\u7684\u533a\u522b\u3002<\/code><\/li>\n<\/ol>\n<h1>\u4e03\u3001\u6807\u7b7e<\/h1>\n<ol>\n<li>\u547d\u4ee4git tag &lt;name&gt;\u7528\u4e8e\u65b0\u5efa\u4e00\u4e2a\u6807\u7b7e\uff0c\u9ed8\u8ba4\u4e3aHEAD\uff0c\u4e5f\u53ef\u4ee5\u6307\u5b9a\u4e00\u4e2acommit id\uff1b<\/li>\n<li>git tag -a &lt;tagname&gt; -m \u201cblablabla\u2026\u201d\u53ef\u4ee5\u6307\u5b9a\u6807\u7b7e\u4fe1\u606f\uff1b<\/li>\n<li>git tag -s &lt;tagname&gt; -m \u201cblablabla\u2026\u201d\u53ef\u4ee5\u7528PGP\u7b7e\u540d\u6807\u7b7e\uff1b<\/li>\n<li>\u547d\u4ee4git tag\u53ef\u4ee5\u67e5\u770b\u6240\u6709\u6807\u7b7e\u3002<\/li>\n<li>\u547d\u4ee4git push origin &lt;tagname&gt;\u53ef\u4ee5\u63a8\u9001\u4e00\u4e2a\u672c\u5730\u6807\u7b7e\uff1b<\/li>\n<li>\u547d\u4ee4git push origin \u2013tags\u53ef\u4ee5\u63a8\u9001\u5168\u90e8\u672a\u63a8\u9001\u8fc7\u7684\u672c\u5730\u6807\u7b7e\uff1b<\/li>\n<li>\u547d\u4ee4git tag -d &lt;tagname&gt;\u53ef\u4ee5\u5220\u9664\u4e00\u4e2a\u672c\u5730\u6807\u7b7e\uff1b<\/li>\n<li>\u547d\u4ee4git push origin :refs\/tags\/&lt;tagname&gt;\u53ef\u4ee5\u5220\u9664\u4e00\u4e2a\u8fdc\u7a0b\u6807\u7b7e\u3002<\/li>\n<\/ol>\n<h1>\u516b\u3001\u914d\u7f6e<\/h1>\n<p>\u5728\u7528\u6237\u76ee\u5f55\u521b\u5efa~\/.gitconfig<\/p>\n<pre>[alias]\r\nst = status\r\nbr = branch\r\nco = checkout\r\nci = commit\r\n[color]\r\nbranch = auto\r\ndiff = auto\r\nstatus = auto\r\n[color \"branch\"]\r\ncurrent = yellow reverse\r\nlocal = yellow\r\nremote = green\r\n[color \"diff\"]\r\nmeta = yellow bold\r\nfrag = magenta bold\r\nold = red bold\r\nnew = green bold\r\n[color \"status\"]\r\nadded = yellow\r\nchanged = green\r\nuntracked = cyan\r\n[user]\r\nname = xxxx\r\nemail = xxxx@qq.com\r\n[core]\r\nautocrlf = input<\/pre>\n<h1>\u4e5d\u3001\u642d\u5efaGit\u670d\u52a1\u5668<\/h1>\n<h3><strong>1\u3001\u521b\u5efa\u7528\u6237\u548c\u7528\u6237\u7ec4<\/strong><\/h3>\n<pre># groupadd git\r\n# useradd -g git git<\/pre>\n<h3><strong>2\u3001\u521d\u59cb\u5316<\/strong><\/h3>\n<pre># git init --bare guohu.git<\/pre>\n<p>3\u3001\u5ba2\u6237\u7aef\u7684\u516c\u94a5\u52a0\u5165\u5230git\u670d\u52a1\u5668\u4e2d<\/p>\n<pre># \u5728\u5ba2\u6237\u7aef\u521b\u5efa\u516c\u94a5\r\n# ssh-keygen -t rsa -C \"xxx@qq.com\"\r\n\r\n# \u5c06\u516c\u94a5\u7684\u5185\u5bb9\u590d\u5236\u5230git\u670d\u52a1\u5668\r\n# scp id_rsa.pub root@192.168.80.110:\/data\/www\/\r\n\r\n#\u5728git\u670d\u52a1\u5668\u4e0a\uff0c\u5c06\u5ba2\u6237\u7aef\u7684\u516c\u94a5\uff0c\u5199\u5165\u5230 \/home\/git\/.ssh\/authorized_keys,\r\n#\u5982\u679c\u6ca1\u6709.ssh\/authorized_keys,\u624b\u52a8\u5728git\u670d\u52a1\u5668\u4e0a\u521b\u5efa\u3002\r\n# cat id_rsa.pub &gt; \/home\/git\/.ssh\/authorized_keys\r\n# \u6ce8\u610f authorized_keys \u7684\u6743\u9650\u5fc5\u987b\u662f600\r\n\r\n#\u5728\u5ba2\u6237\u7aef\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u62c9\u5206\u652f\r\n#git clone git@192.168.80.110:\/data\/git\/guohu.git\r\n\u6216\u8005\r\ngit remote add origin git@192.168.80.110:\/home\/git\/shopx.git\r\n# \u6ce8\u610f\u786e\u4fdd \/home\/git\u76ee\u5f55\u7684\u6587\u4ef6\uff0c\u5fc5\u987b\u662fgit\u7684\u7528\u6237\u548c\u7528\u6237\u7ec4\r\n# \u5f88\u5947\u602a\uff0c\u521b\u5efa\/home\/git\u76ee\u5f55\u4e0b\u624d\u6210\u529f<\/pre>\n<h3><strong>4\u3001\u7981\u7528shell\u767b\u5f55<\/strong><\/h3>\n<p>\u51fa\u4e8e\u5b89\u5168\u8003\u8651\uff0c\u7b2c\u4e8c\u6b65\u521b\u5efa\u7684git\u7528\u6237\u4e0d\u5141\u8bb8\u767b\u5f55shell\uff0c\u8fd9\u53ef\u4ee5\u901a\u8fc7\u7f16\u8f91<code>\/etc\/passwd<\/code>\u6587\u4ef6\u5b8c\u6210\u3002\u627e\u5230\u7c7b\u4f3c\u4e0b\u9762\u7684\u4e00\u884c\uff1a<\/p>\n<pre><code class=\"ruby\"><span class=\"symbol\">git:<\/span><span class=\"symbol\">x:<\/span><span class=\"number\">1001<\/span><span class=\"symbol\">:<\/span><span class=\"number\">1001<\/span><span class=\"symbol\">:<\/span>,,,<span class=\"symbol\">:\/home\/git<\/span><span class=\"symbol\">:\/bin\/bash<\/span>\r\n<\/code><\/pre>\n<p>\u6539\u4e3a\uff1a<\/p>\n<pre><code class=\"ruby\"><span class=\"symbol\">git:<\/span><span class=\"symbol\">x:<\/span><span class=\"number\">1001<\/span><span class=\"symbol\">:<\/span><span class=\"number\">1001<\/span><span class=\"symbol\">:<\/span>,,,<span class=\"symbol\">:\/home\/git<\/span><span class=\"symbol\">:\/usr\/bin\/git-shell<\/span>\r\n<\/code><\/pre>\n<h3><strong>5\u3001\u7ba1\u7406<\/strong><\/h3>\n<ul>\n<li>\u642d\u5efaGit\u670d\u52a1\u5668\u975e\u5e38\u7b80\u5355\uff0c\u901a\u5e3810\u5206\u949f\u5373\u53ef\u5b8c\u6210\uff1b<\/li>\n<li>\u8981\u65b9\u4fbf\u7ba1\u7406\u516c\u94a5\uff0c\u7528Gitosis\uff1b<\/li>\n<li>\u8981\u50cfSVN\u90a3\u6837\u53d8\u6001\u5730\u63a7\u5236\u6743\u9650\uff0c\u7528Gitolite\u3002<\/li>\n<\/ul>\n<h1>\u5341\u3001\u5e38\u7528\u7684\u547d\u4ee4<\/h1>\n<pre>--pretty=oneline\u3001--no-ff\u3001--graph\u3001--abbrev-commit<\/pre>\n<h1>\u5341\u4e00\u3001\u751f\u6210ssh\u79c1\u94a5\u3001\u516c\u94a5<\/h1>\n<pre># ssh-keygen -t rsa -C \"xxx@qq.com\"<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u770b\u4e86\u4e00\u4e9bGit\u7684\u6559\u7a0b\uff0c\u6709\u4e00\u4e9b\u6307\u4ee4\u8fd8\u662f\u8ba9\u4eba\u6026\u7136\u5fc3\u52a8\u7684\uff0c\u751f\u6015\u81ea\u5df1\u5fd8\u8bb0\u4e86\uff0c\u8fd9\u91cc\u505a\u4e00\u4e2a\u7b14\u8bb0\uff0c\u770b\u5230\u8fd9\u4e2a\u7b14\u8bb0\u80fd\u591f\u9a6c\u4e0a\u60f3\u8d77\u6765\u3002\u5982\u679c\u9700\u8981\u5bf9Git\u8be6\u7ec6\u4e86\u89e3\u7684\uff0c\u53ef\u4ee5\u53bb\u5b98\u65b9\u7f51\u7ad9\u67e5\u770b\uff0c\u8fd9\u91cc\u8d34\u51fa\u4e00\u4e2a\u5b98\u65b9\u4e2d\u6587\u7248\u7684\u7535\u5b50\u4e66\uff1ahttps:\/\/git-scm.com\/book\/zh\/v2 &nbsp; \u5173\u4e8eGit \u7684\u5386\u53f2\u7531\u6765\uff0c\u4ee5\u53ca\u4e8e\u96c6\u4e2d\u5f0f\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff08\u5982svn\u3001cvs\uff09\u7684\u533a\u522b\uff0c\u4ee5\u53ca\u5b89\u88c5git\uff0c\u8fd9\u91cc\u5c31\u4e0d\u4ecb\u7ecd\u4e86\u3002\u8865\u5145\u4e0b\uff0c\u5386\u53f2\u7531\u6765\u5176\u5b9e\u5f88\u6709\u610f\u601d\uff0c\u5475\u5475!! \u4e00\u3001\u521d\u59cb\u5316\u672c\u5730\u7248\u672c\u5e93 \u521d\u59cb\u5316\u4e00\u4e2aGit\u4ed3\u5e93\uff0c\u4f7f\u7528\u00a0git init\u00a0\u547d\u4ee4\u3002 \u6dfb\u52a0\u6587\u4ef6\u5230Git\u4ed3\u5e93\uff0c\u5206\u4e24\u6b65\uff1a \u4f7f\u7528\u547d\u4ee4git add &lt;file&gt;\uff0c\u6ce8\u610f\uff0c\u53ef\u53cd\u590d\u591a\u6b21\u4f7f\u7528\uff0c\u6dfb\u52a0\u591a\u4e2a\u6587\u4ef6\uff1b\u4e5f\u53ef\u4ee5\u4f7f\u7528\u00a0git add *\u00a0\uff0c\u6dfb\u52a0\u6240\u6709\u6587\u4ef6\u3002 \u4f7f\u7528\u547d\u4ee4git commit\uff0c\u5b8c\u6210\u3002\u6216\u8005\u4f7f\u7528\u00a0git commit -a\uff0c\u63d0\u4ea4\u6240\u6709\u6587\u4ef6\uff0c\u5305\u62ec\u672a git add \u7684\u6587\u4ef6\u3002 \u4e8c\u3001\u7248\u672c\u56de\u9000 \u4f7f\u7528\u00a0git log\u00a0\u67e5\u770b\u64cd\u4f5c\u8bb0\u5f55\uff0c\u5982\u679c\u65e5\u5fd7\u5185\u5bb9\u5f88\u591a\u53ef\u4ee5\u4f7f\u7528\u00a0git log \u2013pretty=oneline \u4f7f\u7528git reflog\u67e5\u770bHEAD\u7684\u547d\u4ee4\u7684\u5386\u53f2\u8bb0\u5f55\u3002 \u4f7f\u7528git reset HEAD\u00a0\u8fd4\u56de\u5230\u4e0a\u6b21\u63d0\u4ea4\uff0cgit reset HEAD^^\u00a0\u8fd4\u56de\u5230\u4e0a2\u6b21\u7684\u63d0\u4ea4\u3002\u5982\u679c\u52a0\u4e0a\u53c2\u6570\u00a0&#8211; -hard\uff0c\u5219\u653e\u5f03\u5f53\u524d\u7684\u4fee\u6539\uff0c\u8fd9\u91cc\u4e0d\u5305\u62ec\u65b0\u589e\u6587\u4ef6\uff0c\u56e0\u4e3a\u65b0\u589e\u7684\u6587\u4ef6\u8fd8\u672a\u88abgit\u8ddf\u8e2a(Untracked). \u4f7f\u7528git reset\u00a0&lt;\u7248\u672c\u53f7&gt;\uff0c\u53ef\u4ee5\u4f7f\u7528git reflog\u5148\u67e5\u770b\u7248\u672c\u3002\u3002\u5982\u679c\u52a0\u4e0a\u53c2\u6570 \u2013 -hard\uff0c\u5219\u653e\u5f03\u5f53\u524d\u7684\u4fee\u6539\uff0c\u8fd9\u91cc\u4e0d\u5305\u62ec\u65b0\u589e\u6587\u4ef6\uff0c\u56e0\u4e3a\u65b0\u589e\u7684\u6587\u4ef6\u8fd8\u672a\u88abgit\u8ddf\u8e2a(Untracked)\u3002\u4f8b\u5982\uff1a git reset \u2013hard fb9e84b \u4e09\u3001\u56de\u6eda git reset \u2013hard 5154589 git fetch origin\/dev\u00a0\u548c\u00a0git pull git reset origin\/dev \u4e09\u3001\u7248\u672c\u64a4\u9500 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-18559","post","type-post","status-publish","format-standard","hentry","category-docker"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18559","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=18559"}],"version-history":[{"count":1,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18559\/revisions"}],"predecessor-version":[{"id":18560,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18559\/revisions\/18560"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=18559"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=18559"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=18559"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}