Reputation: 65
How can I find commit in all branches? In my case it is more than 20 branches and I've only part of commit id. I know only that it is part of begin or end commits id. All branches excludes one are remote.
Upvotes: 5
Views: 1097
Reputation: 6904
I think what you're looking for is a combination --contains
option with finding a commit from the revision list using rev-list
git branch -a --contains $(git rev-list --all | grep <your-partial-commit-id>)
It finds first the full commit id using the partial with
git rev-list --all | grep <your-partial-commit-id>
And then you pass the full commit id to search in all the branches using the -a option (for all branches), with the commit id passed to the --contains
argument
git branch -a --contains <your-full-commit-id>
Additional Note: In your case, this is not true, but if it is known that the partial id is the beginning part of the full commit id (any length), then you can just directly pass it to git branch --contains
without getting the full id from the rev-list
command
Upvotes: 6
Reputation: 3258
this command will save your life
git reflog
reference here
Upvotes: 0
Reputation: 63154
git rev-list --all | grep <your-partial-sha1>
... will output all of the commits from your repository whose SHA-1 matches.
Upvotes: 0