To search the commit log (across all branches) for the given text:
(要搜索给定文本的提交日志(跨所有分支):)
git log --all --grep='Build 0051'
To search the actual content of commits through a repo's history, use:
(要通过回购历史记录搜索提交的实际内容,请使用:)
git grep 'Build 0051' $(git rev-list --all)
to show all instances of the given text, the containing file name, and the commit sha1.
(显示给定文本的所有实例,包含文件名和提交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
:
(最后,作为最后的手段,如果您的提交悬空并且根本没有连接到历史记录,您可以使用-g
标志搜索reflog本身( --walk-reflogs
:)
git log -g --grep='Build 0051'
EDIT: if you seem to have lost your history, check the reflog
as your safety net.
(编辑:如果您似乎丢失了历史记录,请将reflog
作为您的安全网。)
Look for Build 0051 in one of the commits listed by (在列出的其中一个提交中查找Build 0051)
git reflog
You 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.
(您可能只是将HEAD
设置为历史记录的一部分,其中“Build 0051”提交不可见,或者您可能实际上将其吹走了。)
The git-ready reflog article may be of help. (git-ready reflog文章可能会有所帮助。)
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)
(要从reflog中恢复您的提交 :执行您找到的提交的git checkout(并可选择创建一个新的分支或标记以供参考))
git checkout 77b1f718d19e5cf46e2fab8405a9a0859c9c2889
# alternative, using reflog (see git-ready link provided)
# git checkout HEAD@{10}
git checkout -b build_0051 # make a new branch with the build_0051 as the tip