简体   繁体   English

GIT回到旧版本

[英]GIT back to an older version

I have 2 branches on my git repository (Master and Version1). 我的git信息库(Master和Version1)上有2个分支。 Currently I am working on the branch Version1 (several files). 目前,我正在分支Version1(几个文件)上工作。 Now i want to get back to an older Versions ( 0780033 --> several commits before) - all files should be changed to that version; 现在我想回到较旧的版本( 0780033 >之前几次提交)-所有文件都应更改为该版本; but i don't want to delete the previous - i just want to "copy" this old version and paste it, so that the copy of 0780033 is my actual version. 但我不想删除以前的版本-我只想“复制”此旧版本并将其粘贴,以便0780033的副本是我的实际版本。 I am not sure if I should use reset, or checkout or revert? 我不确定是否应该使用重置,检出或还原?

AFAIK, you should checkout to SHA-1 which you want with command: AFAIK,您应该使用以下命令结帐到想要的SHA-1:

git checkout -b old_version <SHA-1>

or with command if you already have created branch: 或使用命令(如果您已经创建了分支):

git checkout <branch_name>

By usage of this commands some files can be modified, additional files which was added in newer version and were untracked shall stay untracked. 通过使用此命令,可以修改某些文件,在较新版本中添加且未跟踪的其他文件应保持未跟踪状态。 On opposite additional files which were added in newer version and commited shall disappear in older version. 相反,在较新版本中添加并提交的其他文件应在较旧版本中消失。

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

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