How can i create a file in git,which should automatically assign the code reviewers based on branch

I have a requirement to create a file in git, which should automatically assign the separate code reviewers based on the branch.

  • I tried by adding  separate codeowners file  to each branch (dev,master,uat and release). So that when i open a pull request, codeowners file will automatically assign the reviewers based on the mentioned code owner in the Branch. ex: for Dev branch i want code owner to be “@A
    • Master ------> “@B”,
    • uat----------> “@C” and
    • release------> “@D

It is actually working, But When i open a pull request and merge from Dev–> Master it is overriding the codeowner with “A” in the Master Branch

I’ve tried keeping codeowners file in the .gitignore file. In this case it is not recognizing the codeowner file itself.

I’ve also tried one of stackoverflow answer .gitattributes , But it is still overwriting the file in other branch.

How can we achieve this in GIT?
Is there any other option like where we can create a single file in git and differentiate the codeowner based on the branches, so that it will automatically assign reviewers when we open the pull request?? Anything helps.

Hi @basireddy423,

This post was moved to a different board that fits your topic of discussion a bit better. This means you’ll get better engagement on your post, and it keeps our community organized so users can more easily find information.

As you’ll notice, your topic is now here in the How to use Git and GitHub board. No action is needed on your part; you can continue the conversation as normal here.

1 Like