Git:回滚到更早的版本 [英] Git: Roll back to much earlier version

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

问题描述

是否有办法回滚到git(对于整个仓库)中已签入的内容的更早版本?我不想更改存储库中的内容,我只想要9个月前存储库所在位置的本地副本.

Is there a way to roll back to a much earlier version of what was checked into git (for the entire repo)? I don't want to change what is in the repo, I just want a local copy of where the repo was 9 months ago.

推荐答案

是的,只需克隆存储库...

Yes, just clone the repo...

git clone <repo-url>

...从9个月前找到所需的提交,分支或标记...

...find the commit, branch or tag you want from 9 months ago...

git log
git branch
git tag

...然后签出旧版本...

...and then checkout the older version...

git checkout <commit-sha1, branch, tag>

请记住,如果您检出一个提交,您将处于分离式HEAD模式.如果您想进一步提交,则可以为该提交创建分支.

Keep in mind if you checkout a commit, you'll be in detached HEAD mode. You can create a branch to that commit if you wish to commit further.

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

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