Somehow I thought I had made and committed changes to a file, but the changes no longer appear in my work tree, diffs, or log --patch
output. I'm pretty confused, and my only guess is that they were inadvertently discarded by the Git diff algorithm during a rebase or merge operation.
I don't believe my repo has been garbage collected recently, so I would like to try and recover these changes before they are lost and I have to redo them.
How can I search through the contents of all commits for a particular string, including those "orphaned" and no longer located on a path between the root and a branch tip?
One possible solution is to use
git log -g -S <string>
This searches the full text of commits in the reflog . You can also specify a path and most of the other typical log
arguments if needed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.