Home > front end >  Using git to track deployable state of code
Using git to track deployable state of code

Time:07-29

As I am not very familiar with git, I am not sure if the following ideas makes sense:

In order to keep track of milestones while developing my code, I wanted to have a dedicated production branch which I always set equal to the current master branch whenever master has reached a deployable state. Then I wanted to switch to production branch and push it to remote deployment repository as in this recipe.

I do not plan to make any changes in the production branch, only move it forward to master from time to time. I am trying to avoid merges that cannot be fast-forwarded.

Does my plan make sense? Would anyone care to give step-by-step instructions how to do it?

Problems that I foresee is that urgend fix is needed in production and should later be merged into master, although master has already progressed with developing some new experimental feature, but many let's keep it simple for now...

CodePudding user response:

Your plan makes sense, and your worry about urgent hotfixes won't be a problem either. To achieve a hotfix, a common approach is to simply branch off of production, make your fixes, and then merge it back into production and deploy it. Then immediately merge production into master. The next time you are ready to deploy something, you'll still be able to fast-forward merge master into production just like before.

Note in this strategy the production branch is optional. Alternatively, every time you deploy something to production, you could tag the commit you deployed with a version number. The most recent tag (usually the highest number) could represent what's in production "now". If you need to do a hotfix the process is similar: branch off of the most recent tag, make the change, tag the new commit and deploy it, and then merge that new tag back into master.

Whether you choose to use tags or a production branch is up to you. I usually prefer to use both, since for hotfixes it's easier to say "go branch off of production" than "go branch off of the most recent tag". Most tools are easier to work with using branches as well.

  • Related