I checked some source code into GIT with the commit message "Build 0051".
However, I can't seem to find that source code any more - how do I extract this source from the GIT repository, using the command line?
Update
- Checked in versions 0043, 0044, 0045 and 0046 using SmartGIT.
- Checked out 0043, and checked in versions up to 0051 on a different branch.
- Checked out 0043 again.
- Now, 0051 has disappeared.
Update
The source code is definitely there, now its a matter of checking it out:
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>
Update
Used the following to retrieve the lost source code:
C:\Source>git checkout HEAD@{10}
Previous HEAD position was aa09ace... 20110819 - 1045 - GL: Intermediate version. File version: v0.5.0 build 0043.
HEAD is now at 77b1f71... 20110819 - 1724 - GL: Intermediate version. File version: v0.5.0 build 0052.
Now, everything is visible in SmartGit again. Problem solved - you guys are the best, especially @shelhamer!
Try this!
To search the commit log (across all branches) for the given text:
To search the actual content of commits through a repo's history, use:
to show all instances of the given text, the containing file name, and the commit sha1.
Finally, as a last resort in case your commit is dangling and not connected to history at all, you can search the reflog itself with the
-g
flag (short for--walk-reflogs
:EDIT: if you seem to have lost your history, check the
reflog
as your safety net. Look for Build 0051 in one of the commits listed byYou may have simply set your
HEAD
to a part of history in which the 'Build 0051' commit is not visible, or you may have actually blown it away. The git-ready reflog article may be of help.To recover your commit from the reflog: do a git checkout of the commit you found (and optionally make a new branch or tag of it for reference)
I put this in my ~/.gitconfig:
Then I can type "git find string" and I get a list of all the commits containing that string in the message. For example, to find all commits referencing ticket #33:
Though a bit late, there is
:/
which is the dedicated notation to specify a commit (or revision) based on the commit message, just prefix the search string with:/
, e.g.:Here
<message>
can be a complex regex pattern consisting of whitespaces, so please make sure to quote/escape when necessary, e.g.:Alternatively, a start point can be specified, to find the closest commit reachable from a specific point, e.g.:
See: git revisions manual.
should do the trick