Smit Shah
Smit Shah

Reputation: 13

Git : Do not allow users to push a new branch to remote repo

Sometimes by mistake some of users tend to push their local branches to a remote repo creating a new branch on the remote repo. How can we disallow the users to create new branches on a remote repo but still allow them to push changes to the existing ones.

Thanks!

Upvotes: 1

Views: 769

Answers (1)

poke
poke

Reputation: 388313

That depends a bit on where your remote repository is. If you have full control over it, creating an update hook would probably be the easiest solution. You would just check the branch name (ref name) with a list of allowed branches, and if it does not match, reject the update.

If you are using Gitolite for access control to your repository, you can also just specify the rules to apply only to known branches and disallow push access to all others.

Upvotes: 3

Related Questions