我有一个 git 项目,结构如下:
Main (which acts as production)
Develop (which acts as pre prod environment and is branched from Main)
Several feature branches (which are branched from Develop).
通常的工作流程是从开发中创建一个新的功能分支,然后将其合并到那里,测试它,然后合并到 Main 中以进行生产。
现在我想添加一个阶段环境,放置在 Develop 和 Main 之间,理想情况下新结构如下:
Main ( prod )
Stage ( pre prod )
Develop ( test environment )
Feature branches
问题是我不知道如何用git重构项目。
我的想法是在本地将
Develop
分支重命名为 Stage
,删除旧遥控器并推送新遥控器。
然后从 Develop
创建一个新的 Stage
分支,并从那里创建几个功能分支。
Git Branch 只是一个指针。因此,您可以轻松地通过几个步骤完成您想要的事情。
git checkout Develop # checkout current Develop branch.
git pull # make sure you are up-to-date
git checkout -b Stage # just create a stage branch from current Develop.
# now you have your Stage branch with full history of Develop branch.
从现在开始,您可以继续在 Develop 分支上进行开发,并合并回 Stage 分支,进行暂存。然后根据您的需要从 Stage 合并到 main(prod)。