-1

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
Fylix
  • 2,551
  • 6
  • 45
  • 72
  • 1
    1. Please check these answers about your task https://stackoverflow.com/questions/74404311/how-to-exclude-several-accounts-for-git-log-with-date-condition + https://stackoverflow.com/questions/6889830/equivalence-of-git-log-exclude-author 2. Try to use (and show even unsuccessful results here) simplified regexp with negation – Lazy Badger Nov 15 '22 at 14:21
  • 1
    First skimmed iteration --author='^((?!@abc\.com$') – Lazy Badger Nov 15 '22 at 14:26

2 Answers2

1

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.

AFAIK there isn't a built-in command to list "the commits whose author do not match that domain".

LeGEC
  • 46,477
  • 5
  • 57
  • 104
1
git shortlog --all -es | grep -v @xyz.com

Explanation:

git shortlog --all -es shows a list of users with their number of commits; like this:

  2023  Oleg Broytman <phd@phdru.name>
    60  Test <test@example.org>

grep -v filters the input by lines that don't contain the pattern.

phd
  • 82,685
  • 13
  • 120
  • 165
  • It's **The Bad Idea (tm)** suggest to using piping and 2 commands, while *it can be done* entirely inside Git – Lazy Badger Nov 15 '22 at 14:18
  • 1
    @LazyBadger What is your answer? The OP has said a single command doesn't work for him. And no, it's not a bad idea to provide a working solution; esp. in case where other solutions don't work or are incomplete. – phd Nov 15 '22 at 14:20
  • Author made mistake somehow in (regexp), I suppose (need more details from his side). As linked answers in my commend to OP show, his commands *are correct* in common sense and syntax, just overcomplicated in pattern (IMNSHO) – Lazy Badger Nov 15 '22 at 14:32