Search code examples
gitgit-pushfast-forward

How can I prevent non-fastforward pushes to selected branch(es) in git?


I would like to protect my git repository so only non master branches can be overwritten. Is there a way to protect only selected branches?


Solution

  • You can use GitEnterprise to setup per-branch permissions (admin) to block non-fastforward pushes using fine-grained access permission.

    And git config --system receive.denyNonFastForwards true will simply do the job if you need to block history changing for all branches.