Search code examples
gitgithubbranchgit-workflow

What is the process of deployment to the correct github branch?


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?


Solution

  • 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.