Git - rewrite commit authors when pushing to mirror repository

Viewed 251

We have a git repository. There is branch A and there is branch B. They have the same contents.

New commits are added to branch A.

The problem:

Create a script that takes all new commits from branch A, apply them to B and change their commit author. The script can have the first new commit as a parameter.

Branch A shouldn't change.

I know how to change the commit authors using git filter-branch but once I do that, I won't be able to merge A to B again.

I tried to cherry pick the commits using git cherry-pick $COMMIT..A but that breaks on merge commits.

Is there some possibility to take the new commits and reapply them on branch them B automatically?

Why we need it

I have a project which is stored in a Git repo. Periodically, we have to also push to customer repository (about once a week), which triggers automatic builds. Unfortunately, we cannot work with customer repo directly, because it's accessible only from their intranet. That means every push to their repository is usually composed from tens of commits from different authors.

The problem is that last week their IT enabled the Verify Committer hook. This hook enforces the rule that a developer can push only their own commits. The customer is a big enterprise company and the setting won't be changed. Therefore, we will have to rewrite commit authors before pushing.

0 Answers
Related