简体   繁体   English

使用Git恢复为较新版本

[英]Revert to a newer version with Git

I am using Git (and versioning as a whole) for some weeks now, and even if it helped me increase my performance, I still didn't understand it all well. 我现在已经使用了Git(以及整个版本),即使它帮助我提高了性能,但我仍然不太了解。

So my question is : if I revert from a commit tagged version 0.6.3 of my project to an older commit (version 0.6.2, eg), is it possible to 're-revert' back to the newer commit of my project (version 0.6.3 in this example) ? 所以我的问题是:如果我从项目的带有提交标记的版本0.6.3还原到较旧的提交(例如版本0.6.2),是否可以“还原”回项目的较新提交(在此示例中为0.6.3版)?

Yes it is possible to revert reverts. 是的,可以还原还原。

Depending on how the revert was performed on of the following options apply: 根据执行还原的方式,以下选项适用:

Using git revert <commit/tag> : 使用git revert <commit/tag>
Simply revert the resulting commit via git revert again. 只需再次通过git revert生成的提交即可。 Reverts executed via git revert are normal commits which simply “reverse” the commit, and obviously the reversal of a reversal is the original. 通过git revert执行的git revert是普通的提交,它们只是“反转”提交,显然,反转的反转是原始的。

Using git checkout <commit/tag> -- file : 使用git checkout <commit/tag> -- file
Simply checkout another commit. 只需签出另一个提交。 All commits are equal and git does not differentiate between older and newer ones. 所有提交都是相等的,并且git不会在新旧提交之间进行区分。

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

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