如何回到Git的最新版本? [英] How to get back to most recent version in Git?

查看:414
本文介绍了如何回到Git的最新版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近从SVN转到了Git,对某些事情有些困惑.我需要通过调试器运行以前版本的脚本,所以我做了git checkout <previous version hash>并且做了我需要做的事情.

I have recently moved from SVN to Git and am a bit confused about something. I needed to run the previous version of a script through a debugger, so I did git checkout <previous version hash> and did what I needed to do.

现在我想回到最新版本,但是我不知道它的哈希值.当我键入git log时,看不到它.

Now I want to get back to the newest version, but I don't know the hash for it. When I type git log, I don't see it.

我该怎么做?另外,有没有比输入哈希更简单的方法来更改版本-例如返回两个版本"或转到最新的时间顺序"?

How can I do this? Also, is there an easier way to change versions than by typing out hashes - something like "go back two versions" or "go to the most chronologically recent"?

推荐答案

git checkout master应该可以解决问题.要返回两个版本,您可以说类似git checkout HEAD~2的内容,但是最好在那时创建一个基于 的临时分支,因此git checkout -b temp_branch HEAD~2

git checkout master should do the trick. To go back two versions, you could say something like git checkout HEAD~2, but better to create a temporary branch based on that time, so git checkout -b temp_branch HEAD~2

这篇关于如何回到Git的最新版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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