i have a git project structured as following:
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).
The usual workflow is create a new feature branch from develop, than merge it there, test it and later merge into Main to go to prod.
Now i want to add a stage environment which will be placed between Develop and Main, ideally the new structure will be the following :
Main ( prod )
Stage ( pre prod )
Develop ( test environment )
Feature branches
The problem is that i don't know how to refactor the project with git.
My idea would be to rename locally the Develop
branch into Stage
, delete the old remote and push the new one.
Than create a new Develop
branching from Stage
and from there create the several feature branches.
Git Branch is just a pointer. As such you can easily do what you want in a few steps.
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.
from now on you can keep development on the Develop branch and merge back to Stage branch, for staging. and then as you wanted merge to main(prod) from Stage.