Alexander Oh
Alexander Oh

Reputation: 25641

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

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

Upvotes: 8

Views: 5731

Answers (3)

Raghvendra Parashar
Raghvendra Parashar

Reputation: 4053

You can also use GUI.

gitk

It will open a GUI, then write your commit message in containing box, and hit enter key.

It will show all matching commits with highlighted.

Upvotes: 1

Pablo Fernandez heelhook
Pablo Fernandez heelhook

Reputation: 12553

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.

Upvotes: 17

VonC
VonC

Reputation: 1328292

You could use the --grep option of git log:

$ git log --all --grep=word

See "How to grep git commits for a certain word": this is for grepping commit messages.

Upvotes: 9

Related Questions