如何加载特定的 git commit?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5224364/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 10:17:26  来源:igfitidea点击:

How do I load a specific git commit?

git

提问by xZise

I cloned a repository and want to switch between to a commit to test my plugin against the core.

我克隆了一个存储库并希望在提交之间切换以针对核心测试我的插件。

回答by Felix Kling

Instead of passing the name of a branch, you can pass any commit ID to checkout:

您可以将任何提交 ID 传递给checkout

git checkout <commit-id>

See the manpage.

man页面

回答by Igor

Step 1:fetch list of commits:

第 1 步:获取提交列表:

git log

You'll get list like in this example:

你会得到这个例子中的列表:

[Comp:Folder User$ git log
commit 54b11d42e12dc6e9f070a8b5095a4492216d5320
Author: author <[email protected]>
Date:   Fri Jul 8 23:42:22 2016 +0300

This is last commit message

commit fd6cb176297acca4dbc69d15d6b7f78a2463482f
Author: author <[email protected]>
Date:   Fri Jun 24 20:20:24 2016 +0300

This is previous commit message

commit ab0de062136da650ffc27cfb57febac8efb84b8d
Author: author <[email protected]>
Date:   Thu Jun 23 00:41:55 2016 +0300

This is previous previous commit message
...

Step 2:copy needed commit hash and paste it for checkout:

第 2 步:复制所需的提交哈希并将其粘贴以进行结帐:

git checkout fd6cb176297acca4dbc69d15d6b7f78a2463482f

Thats all.

就这样。

回答by suatCoskun

In the new git version you have to give "-b" i.e.

在新的 git 版本中,你必须给出“-b”即

git checkout -b fd6cb176297acca4dbc69d15d6b7f78a2463482f