Create private branch on remote repository in git

Koziołek picture Koziołek · Jan 30, 2015 · Viewed 10.7k times · Source

I would like to build specific flow on our company git.

  1. developer create a branch on his local machine and commit there some files.
  2. dev push this branch to remote repo
  3. Other devs cannot access to this branch
  4. after few rounds off pushing dev decide to publish his changes.
  5. merge his private branch into public branch
  6. push that public branch.

In the other words - is it possible to configure private remote branch in public repository?

Answer

Scott Thomson picture Scott Thomson · Jan 30, 2015

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.

  1. Dev creates local branch on local machine and commits away
  2. At the end of the day (or whenever is suitable) dev pushes to his private repo git push jdoe-private my-cool-branch
  3. Dev decides he is happy for the work to be published and possibly merged so can tidy it up and rebase it with impunity
  4. Dev pushes his branch to origin 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.