How to set the receive.denyNonFastForwards on a repository in GitHub

后端 未结 2 1062
说谎
说谎 2021-01-12 07:12

I have a repository hosted on GitHub which has several forks.

How can I set up the config of the main repository to set the receive.denyNonFastForwards

相关标签:
2条回答
  • 2021-01-12 07:58

    Github enterprise edition now has a feature for disabling force pushes. For the ones not using the enterprise edition you can configure a pre-push hook.

    It is a good practice to never force-push to master unless absolutely necessary.

    0 讨论(0)
  • 2021-01-12 08:08

    GitHub does not expose this functionality, though there are two options:

    • GitHub support can set this on a repository.

    • You can emulate this by setting the GitHub repository as a mirror of another repository that you have more control over. Only give write access to the GitHub account to a minimal set of responsible individuals, and to an account used to do the mirroring. The non-GitHub repository would be where you would set receive.denyNonFastForwards, and have everyone push. The mirroring could then be done by a post-receive hook, cron job, or a combination of the two. A reason to go with both would be to get a minimal time lag between the two repositories, and still make sure everything is up to date even if the post-receive hook failed to update GitHub (if GitHub was down, for example).

    0 讨论(0)
提交回复
热议问题