DEV Community


Setup 3-Stages DevEnv (local, staging, live) with just Git + Bash

loouislow profile image Loouis Low ・3 min read

I used to work in many random small startup companies. The truth is, some of the companies don't have the basic development environment that set up with local, staging, and live. The scariest thing ever was they did everything in one single environment. And many of them are pretty anti-pattern and very confident about what they are doing.

So, I wrote a bash script that manipulates on top of the Rsync and Git to create such low-cost solution and this is my Github repository page.

This script discards the complicated set up like the professional CI/CD for who would find this useful. It helps with creating a very practical sort-of-CI/CD-thing. You can modify and adding your innovation onto the script to fit in your style.



  • At first, you have a git account set up with Github or BitBucket and created a new repository for a new project.
  • You are mostly doing software development on your local computer. The project files in this environment are called the local.
  • You pulled the new project repository from Github or BitBucket.
  • You make some new changes to the project files and pushed to Github or Bitbucket server.


  • Let say you set up a new server somewhere at Digital Ocean, for example.
  • With installed deployer may be located at dir /dev, for example.
  • Run the $ ./deployer --deploy to pulling the latest project repository from Github or BitBucket.
  • At /staging directory, you can run testing on the actual server environment, instead of doing it locally on your computer.


  • Once you have satisfied and there are no errors in the /staging directory.
  • You can run $ deployer --deploy command to sync to /live directory.


Let's get started and clone the repository at Github with a Terminal,

$ git clone
$ cd deployer
Enter fullscreen mode Exit fullscreen mode

Run this command to get an overview of what this CLI is offered,

$ ./deployer --help
Enter fullscreen mode Exit fullscreen mode

Step 1

Before anything else, you will need to edit the config.proto file to configure the identity of this script, which is only working for a specific payload (your project files),

# To identify specific payload is located
# To store payload history in-between `local` and `staging`
# PROJECT_NAME="defreeze"

# Set git repository URL (URL must end with `.git`)

# Staging directory (full path required)
# e.g. `/to/your/staging/dir/`
# TO_STAGING_DIR="staging"

# Public or live directory (full path required)
# e.g. `/to/your/production/dir/`
# ~ recommended to use symlink re-routing to this directory
Enter fullscreen mode Exit fullscreen mode

Step 2

Then you are ready to start to load your payload into new a deployer environment,

$ ./deployer --deploy
Enter fullscreen mode Exit fullscreen mode

What this command will do:

  • Check if prerequisites (Rsync, Git) are installed.
  • Create local .git just for deployers use to track changes and history.
  • Create a /staging directory.
  • Check or load the latest payload into /staging directory from PROJECT_NAME.
  • Create a /live directory.
  • Synchronize directory from /staging to /live with an exclusion, (see exclude-list.txt).
  • Output statistics.


Alt Text

Alt Text

Alt Text

Thank you for reading this article. Please heart or unicorn would encourage me to write more about this kind of article next time.

Discussion (0)

Editor guide