search

Home  >  Q&A  >  body text

Confused about using git to deploy test environment and production environment?

I have some doubts about using git to deploy test environment and production environment. I hope the seniors can point out a clear path.

What I am doing now: (First method)

Write the code locally and push it to bitbucket after completion.

Then pull the test branch on bitbucket in the test environment.

If there are no problems with the test, create a pull request on bitbucket. Merge the test branch with the master branch.

Pull the master branch on bitbucket in production.

The second method

I have read many articles before and some people also use this method.

Build git repositories in the test environment and production environment respectively,

Then push directly to the test environment for testing after local development,

Then push to the production environment to run.

Don’t know which of these two methods is better? I'm a little stuck on this right now.
I don’t know which method is more scientific and efficient?

I always feel that my current method is a bit troublesome. Each time you push the bitbucket above, then log into the test server and pull. You need to merge it in bitbucket, and then log in to the server in the production environment to pull the code.

So if we use the second method, is bitbucket completely unnecessary? .

In addition, if you use the first method, you should be able to push the code 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 bitbucket is updated, the production environment will automatically synchronize the code of the main branch on bitbucket. (You should be able to do this using git hock.) But if you do this, do you still need to establish git warehouses on the test environment and production environment servers?

If the production environment and the test environment can automatically synchronize the bitbucket code, how can I do it?

天蓬老师天蓬老师2795 days ago542

reply all(2)I'll reply

  • 高洛峰

    高洛峰2017-05-02 09:33:57

    1. Version management (git/svn) and deployment should be properly isolated (decoupled).

    2. The test system and deployment system only need to know the branch & version number of the target code.

    3. The deployment system should have the ability to deploy any version of code on any branch (the code that needs to be online is not necessarily the latest).

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-02 09:33:57

    Deploy a master branch in the production environment, checkout a branch from the master such as the develop branch in the test environment, checkout a branch such as feature from the master, and then use the develop merge feature branch for testing. After testing, use the master merge feature branch. develop merges master's code every day to keep it up to date.

    reply
    0
  • Cancelreply