Question

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!

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top