4

I need to lock master branch of a git repo. I tried pre-commit hooks but they are only client side hooks, but I want to lock master branch from most of the users. Can anyone tell me the steps for pre-receive hook on git ( I use github) or any better way to lock master?

PS: gitolite is not supported on our licensed version of github.

user1640789
  • 41
  • 1
  • 3
  • possible duplicate of [Is there a way to lock a branch in GIT](http://stackoverflow.com/questions/2471340/is-there-a-way-to-lock-a-branch-in-git) – Michael Durrant Sep 01 '12 at 17:23
  • since master is a branch too this seems like a dupe of the other. – Michael Durrant Sep 01 '12 at 17:24
  • @MichaelDurrant The solutions provided there wont work for me because: gitolite is not supported on our version of github. pre-commit hook is a client side hook(cant request every user to add this hook).whereas I am looking for a server-side hook. – user1640789 Sep 01 '12 at 17:44

2 Answers2

2

Licensed GitHub means "GitHub:enterprise", and that also means, as explained in the article "Migrating from GitHub:FI": no custom hooks allowed.
(See also "How can I add a custom git hook to a GitHub Enterprise repo?")

So I would approach this differently, and maintain not one repo on that server, but two repos (the second being a clone of the first).

Everyone can push to the first one, but only a selected user can push to the second one, which allows him/her to select from the first repo what is eligible to be pushed to the second.
So the 'repo2' represents your 'master' in a way, while 'repo1' represents any other branch that all the other users can push to.
This is a bit similar to this GitHub gist article.

I suggest separating the release engineering team into their own organization.
The developers will have to fork all of the repositories residing in the release engineering team.
The developers will be able to commit to master within their organization.
They must send pull requests in order to get their commits into the release_engineering organizations.

Note: It will take some time to convince the customer that committing to the master branch of acme_developers/foobar is distinct from committing to the master branch of acme_release_engineering/fooba.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

The simple solution is probably to clone and host the repository on gitolite or some other system that supports branch locking, and setup a post-commit hook to mirror to your current github repository if you intend to keep that around. We are currently doing just that with a github clone.

prusswan
  • 6,853
  • 4
  • 40
  • 61