3

I had resolved a bug one month before, but still seems to be there are some issues with it. But I don't even remember what changes I had done so far to fix that. I had noted the bug name that time. So to find its commit Id there is only one way that go through the git log and search in commit messages. I tried this way :

      git log  --author=githubUser | grep "65243" 

But its just returning me the message like :

     merge UI Developers Work #65243

Is there any way to get its commit id by doing grep in to it.

The message in the git log would be in the following format:

    commit <commit_id>
    Author: githubUser <[email protected]>
    Date:   Thu Jul X 15:55:23 2014 +0530

        Bug fixed #65243
1
  • 1
    Take a look at toreks answer. He also mentions the --grep option which allows you to search for a string in the commit message. Commented Aug 11, 2014 at 6:21

2 Answers 2

12

There are two methods to do what you want, depending on exactly what you want.

The first and shortest is to use gitrevisions syntax to specify the "first" revision that contains a given string in its commit message:

git rev-parse :/65243

and:

git show :/65243

Quoting from the documentation linked above:

A colon, followed by a slash, followed by a text, names a commit whose commit message matches the specified regular expression. This name returns the youngest matching commit which is reachable from any ref. If the commit message starts with a ! you have to repeat that; the special sequence :/!, followed by something else than !, is reserved for now. The regular expression can match any part of the commit message. To match messages starting with a string, one can use e.g. :/^foo.

This form of expression names a specific commit (i.e., it has the same usage as a raw SHA-1 ID), which is why git rev-parse will show you the revision-ID and git show will show you the commit itself.


If that picks the wrong revision, use git log --grep=65243 to limit its output to those commits that contain the specified regular expression in their commit messages. The difference is that this looks only at the same revisions that git log would show otherwise (so you may add additional limiters), and shows all matching revisions. That is, you can do things like:

git log --since=... --before=... --author=... --grep=65243 branch~30..branch

to see commits that are reachable from branch but not from branch~30, happened between the two time stamps, have the given author, and contain 65243. (Add --oneline or a --format=pretty:... string to the git log command if desired, etc.)

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! this seems to be exact answer
3

Run git log to get all the commit ids you want by date range, so if you are aware of the month of your changes, you can probably narrow down your search :)

git log --before={2014-02-01} --after={2014-01-01} --author="your name"

ie. in the above example, I'm grabbing all the changes made in the month of January 2014

3 Comments

:- I don't have even single letter of commit id
Do you know the date range of the commit?
It would be 16 Jul 2014, let me try this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.