I rewrote git history with filter-branch & --prune-empty. Now I need to recover some commits with specific message. Can I do that? I don't run git reflog or git gc
Asked
Active
Viewed 49 times
1
-
I think if you can find out the SHA-1 hashes of the commits you nuked, you can bring them back into your branch, in a number of ways. Those commits are probably still in the reflog. – Tim Biegeleisen Aug 21 '17 at 01:29
-
@TimBiegeleisen Yep, I know that they still in the reflog. But I don't know a) how to proceed throught all commits, including deleted (is filter-branch will proceed them too?) and how to restore them based on condition with specific message. – Aleksandr Vishnyakov Aug 21 '17 at 01:42
-
I can also get needed hashes from repo backup and restore them manually, but if it is possible, I want to avoid that and find this commits automatically – Aleksandr Vishnyakov Aug 21 '17 at 01:49
1 Answers
0
You can use git log
to search a commit by commit message.
As mentioned here, git log
has a --grep-reflog
option which allows you to grep commit messages of lost commits.
You can then list the SHA1 only with --format=format:%H
.

VonC
- 1,262,500
- 529
- 4,410
- 5,250