git: how to pull master out into its own repo (so we can change its permissions)

StackOverflow https://stackoverflow.com/questions/20750565

  •  21-09-2022
  •  | 
  •  

Domanda

We currently are using a git workflow where each developer in our small team has his own branch (instances of which live on each of their development machines) as well as master.

We want to be able to prevent junior members from pushing directly to origin/master and so want to put master in its own repository (which from my reading appears to be a fairly standard practice).

Most developers would have r/w access to their branch on origin but only read access to the centralized master.

I understand how to change the git configuration to leave the developer branches pointing to their remote tracking equivalents on origin..and then point master to another location (say, origin2).

My question is: whats the best way to actually extract the master branch out of origin and put it in its own location?

È stato utile?

Soluzione

Whats the best way to actually extract the master branch out of origin and put it in its own location?

Simply add a new remote referencing an empty bare repo, and push master to it.

 git remote add newlocation /url/to/bare/repo
 git push newlocation master

That being said, for fine-grained repo/branch protection, adding an authorization layer like gitolite to your "master" repo remains the surest way to protect what you want how you want it protected.
See that answer for protection examples.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top