Hi, Habrosoobschestvo!
Continuing the topic of using git hooks, I want to tell you about post-merge and post-checkout
What we have
We have a web application that we are developing. We need to quickly and easily add changes to production.
')
What does git offer us
post-merge - This hook is called 'git-merge', after we have executed 'git-pull' or 'git-merge' on the local repository. The hook will fail if we have conflicts with merge.
Post-checkout - This hook is called 'git-checkout' after we execute 'git-clone' or 'git-checkout'.
What we do
The deployment mechanism will be something like this:
1. Raise the git server. We translate all development to git. The tested code is uploaded to the repository.
2. We write hooks that will do what we need to do after deployment. In this case, the post-merge hook.
3. If we want to deploy a working configuration on a clean server, then we write a post-checkout hook
For example, after the deployment we need to clean up some folder and restart the Apache.
Put this script in .git / hooks / post-merge.
We execute git pull and we run this script.
Similarly for post-checkout hook
Pros:
- Fast delivery of changes to production.
- Automation
- Centralized storage of a working web project
Minuses:
- This scheme will not work if we create new branches by git checkout -b newBranch
- This scheme will not work if we manually merge changes to the local storage.
UPD: The goal is not to show the only and kosher kind of deployment, but how you can still use git hooks. And yes, I know about Capistrano, Vlad the Deployer, Chef (solo), Puppet and others.