Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find git commits in the repository by commit message?

Tags:

git

We have recently converted our SVN repositories to GIT. It seems that we lost some commits by this conversion and would like to verify this.

So we would like to find a matching git commit for each svn commit to check whether the conversion has actually occured.

$ git log|grep "some partial commit message" will not suffice as it only walks through direct ancenstors and ignores branches that are not direct ancestors.

$ git show <commit-hash> will not work as svn doesn't have sha1sums.

the closest thing I found was: $ git reflog show --all --grep="releasenotes"|xargs git show --shortstat however this doesn't seem to completely work as it seems to grep in more places than just the commit message (We got a false positive).

I also tried to use this: $ git rev-list --all|xargs -n1 bash -c 'git show|head -n10'|grep -i release

basically I'm lacking a good method to print the commit message without the diffs.

[EDIT]

I'm not exactly sure but I guess this should list all commit messages in the repository.

git rev-list --all|xargs -n1 git log -n1
like image 980
Alexander Oh Avatar asked Dec 19 '12 15:12

Alexander Oh


1 Answers

You can just use the --all option for git log

git log --all --oneline --graph --decorate | grep "message"

Which is equivalent to

git log --all --oneline --graph --decorate --grep "message"

Or if you would prefer to have the context and don't have a lot of commits you might want to do something like

git log --all --oneline --graph --decorate | less
/ message

And that way you can see where your commits are with respect to other commits.

like image 93
Pablo Fernandez heelhook Avatar answered Sep 26 '22 02:09

Pablo Fernandez heelhook