3
[~] $ git branch
* callgraph
  master

How to "suspend" a git branch. For instance, the branch "master" is not up to date, but at this time I want all the team to use the branch "callgraph" - so working on this branch should be disable in order to avoid mistakes.

Then later, I will merge the callgraph with the master and re-activate this branch...

JohnJohnGa
  • 15,446
  • 19
  • 62
  • 87

2 Answers2

3

Locally, you can't restrict anyone to not commit to their local branches.

With e.g. gitolite you can change permissions to make certain branches read only.

The best and simplest way imo is still to communicate to the developers. "Hey, right now we use branch xyz, ok?".

rtn
  • 127,556
  • 20
  • 111
  • 121
2

Why don't you just tell your team to commit to callgraph?

You could for example, create a tag from the master branch and delete it. The tag would just be there to restore the master branch later, any commits to that branch are then rejected (leaving puzzled developers)

If you want to do it via hooks, that's possible - you'd need a pre-receive hook which expects on stdin "oldref newref refs/heads/master". In the pre-receive hook, if it is for the master branch - return a none-zero exit code and the push will be rejected (leaving puzzled developers).

Note that you can always use git push -f to revert master back to any given commit.

AD7six
  • 63,116
  • 12
  • 91
  • 123