Git (maybe) for You
This post is related to my personal blog post here. So, let’s just start it.
As on my team at my previous company that didn’t using git at all, this is step by step to make all the projects git ready. To get more context, these are the conditions (when I left around 2 years ago).
- No using cloud / managed service, we maintain all of the servers by ourselves.
- Most of us coding directly to the development server as we are mainly using PHP for our projects, too lazy to make it run locally (Don’t ever think about containerised them, we don’t even implement git yet).
- Testing environment could be on same server (different folder) or different server.
- There
couldmust be differences codes between production, testing and development.
Ring a bell? or is these similar on your current situation?
Here are what you need to do for each project:
- Prepare the repository server, including for backup. Make the script to backup all repo data daily. This repo server should be accessible (at least using git command) from development, testing and production server.
- For the git itself, I prefer to use gitlab rather than just use plain git. They have community version that can be installed on your own server, choose your best option. Setup the team and project there, read the docs!
- Don’t do any changes on development server for now.
- Init a repo for one project.
- Push everything that running on production to
master
branch. - Add all config files related to .gitignore, backup the files to any other place, delete them.
- Make a
staging
branch with base frommaster
. Copy what’s on testing environment to this branch. Compare it. Resolve anything that conflicts. Push it. - Make a
development
branch with base fromstaging
. Copy what’s on development environment to this branch. Compare it. Resolve anything that conflicts. Push it. - Next, as usually doing development directly to development server, we’ll do the same but now using
development
branch. - Whenever development done, make merge request from
development
tostaging
. Tester can do test on staging. When done testing make merge request fromstaging
tomaster
. Last, deploy it from master.
That’s for a starter. As time goes by, you will get better flow / strategy to your own development process. Each team / project has its own needs that can have different strategy.