I'm pushing a large repo into another on Azure DevOps Repos and I'm getting error because one repo policy only allows author with @abc.com pattern for email.
The push was rejected because one or more commits contain author email 'user1@xyz.com' which does not match the policy-specified patterns
When I run the git command below on my window PC I can see the precise check-in from this user1@xyz.com
git log --name-only --author="user1@xyz.com"
How can I run the git log command to find all commits that are not @abc.com? is there a built in command in git?
My un-successful attempts so far using regex:
git log --name-only --author='@(?!abc\.com)([^.]+\.)+com$' --perl-regexp
git log --name-only --author='^((?!*)abc\.com)$' --perl-regexp
IMHO, the simplest way is:
git log --all --pretty="%h %aE %cE"
will list all author and committer emails for your commits.
You can then process the output however you see fit.
[edit] Since my initial answer, I learned a bit more about the combination of --perl-regexp --author="..."
.
On my laptop, the following gives me a relevant list of commits:
# an '@', followed by something which doesn't start in 'abc.com'
git log --perl-regexp --author='@(?!abc\.com)'
If you additionally want to target domain names that end in .com
: the string that is matched by the regexp is the standard author string stored by git: Author Name <author.email@domain.com>
1 (email is surrounded in angle brackets).
If you want a regexp that matches the very final part of the domain name, you have to add something to match that final >
...
One possibility is:
git log --perl-regexp --author='@(?!abc\.com)[^@]*\.com>$'
1: I got to understand that with this other answer by user dani-vta, and although not documented in the doc for --author=...
, it is the format in which git stores the author string. You can view the raw format by running: git cat-file -p <commit sha>