Reputation: 41480
Is there a way in git to find the first (second, third) git commit that's not my own commit going back in time?
Upvotes: 3
Views: 44
Reputation: 3103
The following commands may prove useful:
git shortlog
git log --committer '^(?!YOURAUTHORNAME).*$' --perl-regexp
or similarly,
git log --author '^(?!YOURAUTHORNAME).*$' --perl-regexp
These two variations of log use a regular expression to say "not my user."
You can find info on these commands here. Obviously replace YOURAUTHORNAME with enough characters of your own username to make it unique. If you absolutely only want the single most recent commit, include the --max-count=1 argument to the log command.
As demonstrated with other answers, there are many ways to produce this, including using other linux tools like grep or sed.
Upvotes: 1
Reputation: 18292
git log | grep -P -B 1 '^Author:.*<(?!${YOUR_EMAIL})' | head -n 1
Replace the string ${YOUR_EMAIL}
with what it should be and you'll get the commit hash of the first commit that doesn't match your email address.
First 3 commits that aren't yours:
git log | grep -P -B 1 '^Author:.*<(?!${YOUR_EMAIL})' | grep ^commit | head -n 3
Upvotes: 0
Reputation: 10041
Good question, not too sure if Git can do this itself, but a bit of help from good old "grep" should do the trick. Try this:
git log | grep "Author:" | grep -v "Author: JohnCrawford" -m 1
Obviously put your own name in it and not mine ;-)
Upvotes: 0