Re: Searching all git objects
- From
Shawn O. Pearce <spearce@spearce.org>
- Date
- Jun 25, 2008, 23:17 UTC
- Message-ID
- <20080625231742.GT11793@spearce.org>
- In-Reply-To
- <E99352BE-5C43-437E-A5E6-622BEEA03DFA@comcast.net>
"Sam G." <ceptorial@comcast.net> wrote:
Show 13 quoted lines
> We recently had a developer make a large commit (mostly centered > around one file) which she believed she properly pushed to a remote > repository last week, but looking at both her repository and the > remote repository, that commit is now nowhere to be found. If somehow > the master branch she was working on in her repository has lost the > reference to the commit through perhaps some errant rebasing, then > perhaps an object containing the commit (or an object containing the > file in that commit) still exists somewhere inside her .git/objects > directory? We haven't done any git-gc recently. If so, how can I > search through every single git object in her objects directory, > searching for perhaps a specific part of the commit string, a line in > the code or the filename of the file which was changed? Any help with > this would be greatly appreciated. Thanks!
Odds are it is in her HEAD reflog. You can look for it with `git log -g`. If you know some part of the commit message you may be able to filter it down with `git log -g --grep=X` or part of the change with `git log -g -SX`.
A coworker just did something like that today and lost his change; looking in the HEAD reflog and cherry-picking the commit recovered it quite easily.
-- Shawn.