3

I'd like to mark a branch I created in my repo as non-mergeable.

I'm not using CI or Jenkins as described in this question. I just need to set this to avoid accidental merge of "experimental" features in the master branch.

Is this possible?

davioooh
  • 23,742
  • 39
  • 159
  • 250

1 Answers1

1

You could check out the protected branches in GitHub

That would avoid any merge unless a status check or a PR review is provided.

The alternative, if you manage your own central Git server, on premise, would be to add hooks in order to prevent merges.
See for instance "pre-receive hook on server-side that refuse any push to master which has any non-linear history"

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks. So there isn't a "native" feature for this in Git? – davioooh Nov 11 '19 at 09:48
  • @davioooh In Git itself alone, no: a branch has not "closed" associated status, because anyone else, in its own cloned repo, could bypass it. Git being decentralized by nature, that status would not be easily enforced. But GitHub offers more (BitBucket or GitLab as well). If you are pushing to your own Git hosting server, then yes, there is a Git-only way: hooks. See my edited answer. – VonC Nov 11 '19 at 09:52