Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A way to restrict Git branch access?

Tags:

git

github

I have four branches in my git repository, which is managed using GitHub:

  • Production
  • Staging
  • Master
  • [person's name]-development

Is there a way to restrict write access to only a single branch ([person's name]-development)? How would I do this?

For reference, a similar question: How to write a git hook to restrict writing to branch?.

like image 223
David542 Avatar asked Jan 08 '12 20:01

David542


People also ask

How do I make a GitHub branch private?

With the -u command, your private-branch will point to the remote repository that you nicknamed as private-remote. This push also create a new branch called private-branch on your private repository.

How do you use branch protection rules?

Step 1: Navigate to your repository homepage at Github. You'll be taken to the repository settings page as shown below. Click on the branches to set the branch protection rules. You'll see the branches page where you can set the default branch for your repository and also add the branch protection rules.


1 Answers

When using GitHub, your best option would be for each developer to have their own fork of the master repository. Everybody pushes to their own repository and somebody with push access to the master repository handles pulling from each developer's repository. This is how most open source projects work.

If using your own Git server, it should be possible to use hooks to prevent users from pushing to wrong branches.

like image 183
Esko Luontola Avatar answered Oct 03 '22 18:10

Esko Luontola