Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Create Public Branch in Git

My team is increasing its usage of git and we'd like to start using a public branch, so that users can do their integrations/merges there, instead of master. How do I make a public branch?

Yes, I am a noob at this. Thanks for your help! :D

like image 726
Jim Fell Avatar asked Mar 17 '23 09:03

Jim Fell


2 Answers

You have to create the branch as usual:

git checkout -b TheBranchToUse

Afterwards you need to make it public to others:

git push -u origin TheBranchToUse
like image 69
khmarbaise Avatar answered Mar 19 '23 05:03

khmarbaise


It depends on the scope of the group of developers to which you want to give access to the repo. If you are talking about an internal group, any repo you have on a server accessible by your employees is enough, as the branches will be there. In which case, the advice from @khmarbaise is accurate. Then, your users can fetch that branch, branch from it, you may merge those branches accordingly through a CI like Jenkins, etc.

On the other hand, if you're talking about open source then you could create a new public repo on github, bitbucket, or any other git host, and simply point your users to the repo. Users would create branches from the master branch of this repo and either push directly to master (yikes!) or submit their own branches/Pull Requests.

If you intend to impose branch-specific permissions then a server-side authorization layer is required, such as Gitolite (or others: http://alternativeto.net/software/gitolite/). With Github, one could control write access to one repo, allow users to fork their own, and merge Pull Requests being submitted.

like image 32
ThatsAMorais Avatar answered Mar 19 '23 07:03

ThatsAMorais