Regarding the deployment of test environment and production environment with git, there are some doubts and entanglements. I hope your predecessors can point out a clear path.
What I’m doing now: (the first method)
Write code locally and push to bitbucket after completion.
Then test the branch on pull bitbucket in the test environment.
If there is no problem with the test, create a pull request in bitbucket. Merge the test branch with the main branch.
Main branch on pull bitbucket in production environment.
The second method
I have read many articles before and some people have also used this method.
Git warehouses are built in the test environment and the production environment respectively.
Then push to test on the test environment after local development.
Then push to the production environment.
I don’t know which of these two methods is better. I’m a little entangled in this right now.
Don’t know which way is more scientific and efficient?
I always feel that I am in a bit of trouble in this way. Every time push bitbucket, then log in to test server pull. Then merge in bitbucket and log in to the pull code of the server that will log in to the production environment.
If the second method is used, is bitbucket completely unnecessary? .
In addition, if the first method is used, it should be possible to develop code and play push to bitbucket. if the development branch on bitbucket changes, the test environment will automatically synchronize the development branch on bitbucket. If the main branch on the bitbucket is updated, the production environment automatically synchronizes the code of the main branch on the bitbucket. (Should use git’s hock should be able to do it. But in doing so, is it still necessary to set up git warehouses on the servers in the test environment and the production environment respectively?
If the production environment and the test environment can automatically synchronize the bitbucket code, how do you do it?
Version management (git/svn) and deployment should be properly isolated (decoupled).
The test system and deployment system only need to know the version number of the branch where the target code is located.
The deployment system should have the ability to deploy any version of code on any branch (code that needs to be online is not necessarily up-to-date).