You can somehow limit the infusion of changes to a specific branch located in the remote repository.

For example, there is a bare repository in which developers make changes, there is a master branch in which only accepted changes join, how to restrict access rights to the master branch in this repository?

Perhaps there are some other ways to protect the repository from unwanted injections?

  • Well, what happened? - Nick Volynkin
  • Nick Volynkin, until I applied your recommendations, I’ll deal with this issue in the near future, I’ll be sure to write about the results. - zsiteru
  • Ok, I'll be waiting) - Nick Volynkin

1 answer 1

This is called "branch protection", in English "branch protection". Many popular git-hosting allow you to protect branches.

For example, here’s what GitHub offers in the settings for each repository:

  • (Basic) Prohibit history rewrite ( git push -f ) or delete a branch.

    Be sure to include this for all stable branches.

  • Change branch only through pull-request. You cannot push commits directly into a branch. You can only create a new feature, create commits in it and offer this branch to pull-request.

    This is very reasonable and convenient if it is your custom to work with ficvettes in your team.

  • Merge pull-request only when all tests have passed successfully.

    If you trust your tests, it is worth including.

  • Distribute these restrictions on admins (repository owners).

    The rules must apply to all.

enter image description here