Branching and merging best practices in Git

前端 未结 3 1571
广开言路
广开言路 2021-01-29 23:14

We have a developer team of 4 and have recently moved to Git. We want to learn best practices regarding workflow with branching and merging.

We are using a lightweight

3条回答
  •  太阳男子
    2021-01-29 23:35

    This always depends on how do you want to work and the team agreement. That said.

    1. A feature starts from the dev branch into its own branch. From the master branch you should only branch hotfixes because the master branch should always be the stable version of your software.
    2. When a feature branch is done, it should be merged into dev, then at some point you should branch your next release from dev (including some features) into a new 'release/*' branch which will be merged into master once it is stabilized and well tested.

    In the Atlassian page you have a very nice explanation of this workflow

    The whole idea with this kind of workflows is to have a stable version branch in which you can work and fix any bug immediately if you need to with enough confidence that it will still be stable and no new feature or refactorization will slip in without noticing.

    Also to have isolation and freedom for each new feature which will be developed in its own branch with no noise from other features. Then finally you will merge your features into your dev branch and from there into the master branch for the next release.

    The only thing I would recommend for you is to learn how to rebase your feature branches on top of the dev branch each time another feature is merged into dev to avoid resolving conflicts on merge time, but in isolation on the feature branch where you know what your changes are.

    It also looks like this question was asked before

提交回复
热议问题