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 could must 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:

  1. 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.
  2. 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!
  3. Don’t do any changes on development server for now.
  4. Init a repo for one project.
  5. Push everything that running on production to master branch.
  6. Add all config files related to .gitignore, backup the files to any other place, delete them.
  7. Make a staging branch with base from master. Copy what’s on testing environment to this branch. Compare it. Resolve anything that conflicts. Push it.
  8. Make a development branch with base from staging. Copy what’s on development environment to this branch. Compare it. Resolve anything that conflicts. Push it.
  9. Next, as usually doing development directly to development server, we’ll do the same but now using development branch.
  10. Whenever development done, make merge request from development to staging. Tester can do test on staging. When done testing make merge request from staging to master. 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.