My company is next to this blog .
We create a master branch for production. My business for web development .
Step:
The developer develops his function / error from the master
git checkout -b feature/featureA git checkout -b bug/B
Thus, we will get the new code already in the released line. In the intermediate server, we use the testing branch. Therefore, when any function wants to pass the test, it will merge with this branch
In the staging server we use
git checkout testing git pull
There is a release branch that handles a hot fix; each hot fix will merge with this branch before merging for master. The idea is that the release branch wraps some commits before merging to handle this, if a problem occurs, just use a command like
git reset
for temporary.
See my full work step
git checkout master
Email comes from boss to fix critical error
git stash git checkout master git checkout -b hotfix/a
do things
git commit git checkout release git merge hotfix/a git checkout master git merge release
In production
git tag -d previous git tag previous git pull
Oops! does not work
git checkout previous
New latch completed
git checkout master git pull
Continue my work
git checkout feature/New git stash pop
Ready to release feature
git checkout release git merge feature/New
This is because all objects in the test branch are ready for deployment. So, when combining all the ready-made functions into the release branch, now you can do the final test.
When everything is now in production, we do
git checkout testing git merge master git checkout release git merge master
Script automation
I think you can look into .git/hooks/post-commit.sample
to connect some script after .git/hooks/post-commit.sample
code? Anyway, I never use it.