我将一些源代码签入GIT,并提交消息“Build 0051”。

然而,我似乎再也找不到那个源代码了——如何使用命令行从GIT存储库中提取这个源代码呢?

更新

使用SmartGIT在0043、0044、0045和0046版本中检出。 签出了0043,并在不同的分支签入了0051之前的版本。 又查了一次0043。 现在,0051已经消失了。

更新

源代码肯定在那里,现在是检查它的问题:

C:\Source>git log -g --grep="0052"
commit 77b1f718d19e5cf46e2fab8405a9a0859c9c2889
Reflog: HEAD@{10} (unknown <Mike@.(none)>)
Reflog message: commit: 20110819 - 1724 - GL: Intermediate version. File version:  v0.5.0 build 0052.
Author: unknown <Mike@.(none)>
Date:   Fri Aug 19 17:24:51 2011 +0100

    20110819 - 1724 - GL: Intermediate version. File version: v0.5.0 build 0052.

C:\Source>

当前回答

git log --grep=<pattern>
            Limit the commits output to ones with log message that matches the
            specified pattern (regular expression).

其他回答

如果变化不是太老,你可以这样做,

git 引用日志

然后签出提交id

git log --grep="Build 0051"

应该能成功

只是git log——all——grep命令的一个小补充: 在我的情况下,我必须转义括号内的消息:

git log --all --grep="\[C\] Ticket-1001: Fix nasty things"

对于任何想要传入精确匹配的任意字符串(并且不担心转义正则表达式的特殊字符)的人来说,git log有一个——fixed-strings选项

git log --fixed-strings --grep "$SEARCH_TERM" 
git log --grep=<pattern>
            Limit the commits output to ones with log message that matches the
            specified pattern (regular expression).