I would like to build specific flow on our company git.
In the other words - is it possible to configure private remote branch in public repository?
The flow that is used in my team is to have complete separate repositories for each team member in addition to origin on the main git server.
git push jdoe-private my-cool-branch
git push origin my-cool-branch
The rationale for this setup for us is to allow devs to freely rebase and avoid the problems that can arise from upstream rebasing and also to have full backups. The separate repositories are only private by convention but would be easy to add access control if required. There is a lot of duplication of data but unless your repo is really huge, this is probably not a concern.
The common solution I know is to agree on "branch namespaces", by prepending some string to branch names. For example, branches that start with "private/" are for private experiments. You'd then get branches like
That keeps the branches separate, and makes it clear what their purpose is. However, that way the branches are still public, because anyone can see and pull them.
If you want to restrict access to these branches based on user, you'd need to have some kind of branch-based access control. There is no such thing in core git, but some git hosting servers allow this (Atlassian Stash for example). I don't know of any server that allows these kind of private branches, but maybe there is one that allows it or lets you script a solution.
Note, however, that what you are asking for is rather unusual. The common solution is the one I outlined above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With