简体   繁体   English

我如何回到以前的Git Commit?

[英]How do I go back to previous Git Commit?

How do I go back to previous commit? 我如何回到之前的提交?

I would like my files to look exactly like all my files did when I committed the below commit. 当我提交下面的提交时,我希望我的文件看起来与我的所有文件完全一样。

$ git log
commit 81cf7fa47adc0923aeabe323778e2783f2e832f5
Date:   Thu Apr 2 21:32:27 2015 +1000

I looked around an so many people have different answers. 我环顾四周,这么多人有不同的答案。

You can always checkout to specific commit in git by following command 您可以通过以下命令随时在git中签出特定提交

git checkout commit_hash

So in you case it will be 所以在你的情况下它会

git checkout 81cf7fa47adc0923aeabe323778e2783f2e832f5

Or HEAD@{1} is the pointer to the one commit back so following will do the same 或者HEAD @ {1}是指向一次提交的指针,所以后面也会这样做

git checkout HEAD@{1}

To See Last Commit : 要查看最后提交:

Way 1 : In Terminal type User$ gitk 方式1:在终端类型用户$ gitk

Way 2 : In Terminal type User$ Git Gui -> Click 'Ammend Last change' radio button On Right Bottom Corner 方式2:在终端类型用户$ Git Gui - >点击右上角的'Ammend Last change'单选按钮

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM