回滚到以前的版本后获取完整的git日志 [英] Getting the full git log after rolling back to a previous version

查看:188
本文介绍了回滚到以前的版本后获取完整的git日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是git的新手,可能没有使用正确的术语,所以请忍受:)

I'm new to git, and probably not using correct terminology, so bear with me :)

假设我有一个包含5个更改的存储库,例如

Let's say I have a repository with 5 changes, e.g.

D:\test\gitrepo2>git log --oneline
3a5fd33 555
3cfbfae 444
e9a78c8 333
a618586 222
b80d5e1 111

我了解到可以通过执行以下操作来同步回早期版本:

I learned that I can sync back to an earlier revision by doing:

D:\test\gitrepo2>git reset e9a78c8 --hard
HEAD is now at e9a78c8 333

我的问题是:这样做之后,如何获取完整的日志,以便可以返回到最新版本?

运行日志不再显示这些修订版本:

Running log no longer shows those revisions:

D:\test\gitrepo2>git log --oneline
e9a78c8 333
a618586 222
b80d5e1 111

我也尝试添加--all开关,这没有什么不同.在Mercurial中,在相同的情况下,即使我更新到较早的修订版,运行'hg log'也会提供完整的日志.

I also tried add the --all switch, which didn't make a difference. In Mercurial, under the same scenario, running 'hg log' gives the complete log even after I update to an earlier revision.

推荐答案

我认为通过同步回",您的意思是您实际上只是希望工作副本看起来像以前的某个时间点.为此,您需要的是checkout,而不是reset:

I assume by "sync back" you really mean you just want your working copy to look like a previous point in time. To do that, you want checkout, not reset:

> git checkout e9a78c8

此时,您的存储库如下所示:

At that point, your repository looks like this:

> git log master --oneline
3a5fd33 555   <--- master is still here
3cfbfae 444
e9a78c8 333   <--- HEAD (working copy) is here
a618586 222
b80d5e1 111

现在返回到master上的最新提交,只需再次git checkout master.

Now to get back to the latest commit on master, just git checkout master again.

通过使用reset,您得到的是:

By using reset, you got this instead:

> git log master --oneline
e9a78c8 333   <--- HEAD (working copy) and master are here
a618586 222
b80d5e1 111

这篇关于回滚到以前的版本后获取完整的git日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆