1

I have 3 branches, namely branch master, branch staging and branch prod

besides that I have 2 servers, namely staging server and production server

When I have finished the development process on my localhost, I will push it to the branch master. after that I pull the request to the staging branch and after that merge to the staging branch. then deploy to the staging server. The tester will do the testing on the staging server. If the test results are ok, I will pull the request to the prod branch and merge to the prod branch. then deploy to production server

Is my way correct?

Deepak Terse
  • 652
  • 8
  • 30
moses toh
  • 12,344
  • 71
  • 243
  • 443

1 Answers1

1

This process is absolutely correct and this is how it is ideally followed across the industry. However, it requires slight modifications.

Create a feature branch for every new feature/bug from the master branch and then merge it back to master after it is done. This is done to ease up parallel development of the functionalities. Then you can follow the workflow you mentioned.

To manage some critical projects, you might want the main repository to be clean, so you allow your developers to work on their own fork (a personal copy of the main repository). After completing the task you could raise the PR to the main branch of the main repo and then follow the usual workflow.

Theres one more case where you might need an alternate approach i.e. a hotfix. What is hotfix?

It is any kind of minor change which is very critical. Eg. You pushed your code to production with one of the API still pointing to "localhost". This kind of issue require immediate attention and you don't want your users to drop off. So you go with hotfix where you push your code directly to production.

Note: Git workflow might vary for different individuals or organizations best suited as per their needs. So, it's totally up to you on how critical the project is and how complex workflow you could afford to have.

Deepak Terse
  • 652
  • 8
  • 30
  • @happy forever are you satisfied with the above answer or are you looking for something else? – Deepak Terse May 18 '20 at 12:49
  • I want to confirm 1 thing. What is the correct order? Is the sequence correct starting from branch master -> branch staging -> branch production? Or branch staging -> branch production -> branch master? – moses toh Jun 03 '20 at 02:40
  • master -> staging -> production. The reason is we do usually have a CI implemented on staging and production. So, it is recommended that we test the code locally after the merge, then on staging and production. – Deepak Terse Jun 03 '20 at 03:58
  • I read some references, the sequence is development -> staging -> production / master. so production and master are the same – moses toh Jun 03 '20 at 08:24
  • Different organizations might follow different approaches. I do personally prefer the approach I mentioned above and I do have a reason. So, you have to understand the reason behind following these approaches and analyze what suits you better. Remember, there's no right or wrong over here. It's just a personal choice. – Deepak Terse Jun 03 '20 at 12:33
  • Here, we are talking about these 2 workflows. There are several other workflows that are totally different from the above 2. – Deepak Terse Jun 03 '20 at 12:43