Is there any way of preventing a developer from checking out a different branch? My problem is quite simple: someone from my team keeps checking out a different branch on a production environment, which can of course cause all kind of problems with the code that shouldn't end up there or code that was there but disappeared after the checkout.
I checked a list of possible git hooks here https://www.kernel.org/pub/software/scm/git/docs/githooks.html but I was unable to find any hook that could be useful in such a case.
Also, I found a similar question (Prevent a checkout in Git) where it was suggested to use a script instead of the git checkout
command in the workflow. But it doesn't really solve my problem as I'm not even sure if the checkout is made manually by some dev not knowing git, or is because of improperly configured IDE that as a result of bad configuration and linking local project to a remote one makes the checkout automatically, so the developer using it isn't even aware of that. In such a case, even if I used scripts instead of the git checkout
, I would still have to disable the standard git checkout
.
Does anyone know a solution for that? Or maybe a post-checkout
hook can be used to checkout back? It's still better than nothing.