Search code examples
gitgithooksgit-push

Pushing to checked out branch and executing git hook after


I have been setting up some Git hooks on my remote GitHub and it seems like I ran into a dilemma.

I have a hook that calls a Makefile to deploy my web application in my Git repository and that hook executes post-update when a push to master is detected. However, pushing to the checked out branch of a remote repository is no good to do and otherwise fails. It is rather recommended to have a bare repository when pushing. However, if the repository is bare then my Git hooks cannot be executed properly since all the files are essentially blobs.

What are my options for fixing this issue? I can always push a branch and merge it into master (have a post-merge hook instead of a post-update hook) but that would entail having to SSH into my server to do the merge and defies the whole point of the hook...


Solution

  • Your case is the reason allowing the push is configurable.