2

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?

Brian Tarbox
  • 2,335
  • 1
  • 20
  • 30
  • 1
    why not use something like gitolite for permissions? http://gitolite.com/ – jshawl Dec 23 '13 at 20:43
  • Clone the repo, delete every other branch? – Ismail Badawi Dec 23 '13 at 20:56
  • I'd say extracting a single branch to a separate git just to be able to apply stricter access control is atypical and indicates that you're not using the best tools for the job. Apart from Gitolite that's mentioned in another comment, Gerrit Code Review allows per-branch write access. – Magnus Bäck Dec 23 '13 at 22:57

1 Answers1

0

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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250