【 Git 二】版本回退
<h3>版本回退</h3>
<hr />
<h5>1. 输出详情信息</h5>
<pre><code>git log</code></pre>
<h5>2. 输出简化信息</h5>
<pre><code>git log --pretty=oneline</code></pre>
<p><img src="https://www.showdoc.cc/server/api/common/visitfile/sign/7da0fb0a119c615230a159bbae1f4c84?showdoc=.jpg" alt="" /></p>
<h5>3. 指定回到某个版本</h5>
<pre><code>git reset --hard 1094a</code></pre>
<p>版本号没必要写全,前几位就可以了,Git会自动去找。当然也不能只写前一两位,因为Git可能会找到多个版本号,就无法确定是哪一个了。</p>
<h5>4. 记录你的每一次命令</h5>
<pre><code>git reflog</code></pre>
<h5>小结</h5>
<p>现在总结一下:</p>
<p>HEAD指向的版本就是当前版本,因此,Git允许我们在版本的历史之间穿梭,使用命令git reset --hard commit_id。</p>
<p>穿梭前,用git log可以查看提交历史,以便确定要回退到哪个版本。</p>
<p>要重返未来,用git reflog查看命令历史,以便确定要回到未来的哪个版本。</p>