3

I have a pretty basic problem I'm trying to solve on Github. I have a private repository (via an Organization), and I need to figure out the best way to set it up so that my team can do pushes to a branches beneath the master branch, but not the master branch itself.

I know one way would be to have two separate private repositories, one which would be the "master" repository, and the other that would be the "staging" repository. And then only I would have access to the "master" repo, but the team would have access to the "staging" repo. And then I would merge the changes from "staging" to "master".

But I'm not sure I understand how to go about creating the "staging" repo off the "master" repo, nor how to merge changes back into "master".

Here is a rough diagram of what I'm trying to accomplish (above the line, "master" repo, below the line, "staging" repo):

master (only me)
-----------------------------
--> staging (team)
    --> feature 1
        --> team member 1
    --> feature 2
        --> team member 2
        --> team member 3

Any ideas?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Jerad Rose
  • 15,235
  • 18
  • 82
  • 153
  • Create a repository for your project on github and then add another branch named *staging*. At this point you'll 2 branches: **master** and **staging**. Tell your code monkeys to only work on the *staging* branch. – karlphillip Jun 27 '11 at 17:51
  • @karlphillip: it sounds like he is looking for a way to restrict his monkeys to only the staging branch. – X-Istence Jun 27 '11 at 17:53
  • You can fork a repository into an organisation, so create a fork of a repository and add all of the other people as members that can commit to that fork. You have access to both and can thus move stuff from "staging" to "master". – X-Istence Jun 27 '11 at 17:54
  • @karlphillip - What X-lstence said. :) I already have it set up like you said, but would prefer to ensure they don't accidentally (or intentionally) push to the master branch. – Jerad Rose Jun 27 '11 at 17:55
  • @X-lstence - Another noob question... Why is a fork a one-time action, meaning, I can't create multiple forks from the same branch? It seems like what I want is a branch, not a fork, as I won't be working from this "staging" fork, but rather, my team will. I may have another fork I wish to work from off "master", but now my only fork has been used up for the "staging" fork (plus, it forces me to name the fork "jeradrose"). – Jerad Rose Jun 27 '11 at 18:02
  • @Jerad I completely understand your concern, but on the other hand, if you can't trust them to commit code to the right place, it's time to hire new monkeys. Another low tech approach is simply to force them to create a global *alias* to the command `git push origin staging` and tell them to always use the alias instead of executing `git push` themselves. – karlphillip Jun 27 '11 at 18:07
  • @karlphillip - My monkeys are volunteers ([long story](http://www.animalcrossingcommunity.com/Topic/5310652/1/)), so I take what I can get. :) – Jerad Rose Jun 27 '11 at 18:09
  • @Jerad In that case, you probably want separate repositories too. – karlphillip Jun 27 '11 at 18:10

1 Answers1

3

With a DVCS, branching and publication (push/pull) are two orthogonal concepts.

That means you shouldn't be concerned to what branches your collaborators are pushing to, as long as they are pushing to their own (forked) private repo on GitHub.
You are the only one able to import what they propose (through pull request) in the branch of your choosing in your private repo.

When I see lifecycle steps ("staging", "testing", "QA", "..."), I prefer setting up a separate repo for each step I need, in order to have as many branches as I want in each of those separate repos.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • This makes much more sense out of what I was trying to do. Thanks for the explanation. – Jerad Rose Jun 28 '11 at 13:28
  • Sorry, one quick question. So if I were to set up a separate repo for my lifecycle steps, do I go about this by forkinig my master repo, or is there another method to do this that will not "consume" my fork, so that I can still fork from the master (and other) repos? Hope that makes sense. Thanks again. – Jerad Rose Jun 28 '11 at 13:34
  • @Jerad: since your forked private repo is still private (http://www.quora.com/If-you-fork-a-private-repository-on-Github-is-your-fork-made-private-by-default), maybe you can ask a collaborator to, in turn, fork the fork? But much more simply, I would just do multiple clones of my private repo, and push them back to multiple private repo on GitHub. – VonC Jun 28 '11 at 13:54