Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Setup auto-deployment using

Setup auto-deployment using

how to setup auto-deployment using with shell commands

1. Setup on server

  1. Login your server with ssh.

  2. Make repo directory to clone your repository as mirror repository.

     $ mkdir repo
  3. Change directory and git clone with --mirror. Then your is cloned in repo directory.

     $ cd repo/; git clone --mirror<username>/<repo-name>.git <repo-name>
  4. Make directory for production repository.

     $ mkdir ../path/to/production-repo
  5. Make sure path with $ pwd if you need.

  6. Change directory to your mirror repo and do an initial checkout:

     $ cd ../repo/mirror-repo/; GIT_WORK_TREE=/path/to/production-repo git checkout -f master

2. Check

cd /path/to/production-repo; ls -la

3. Setup on

General settings

  • Name: something else like "production-name"

Server details

  • Host: your server's host name
  • Port: your server's port number
  • Working directory: path to your mirror-repo [NOT production-repo]
  • Login : your name for login to server
  • Password or Use public key for authentication

If you use public key for authentication,

  1. Check `[Show the commands to add our public key to your server.].
  2. Copy and paste the command to your server.


Enter below these shell commands.

$ cd /path/to/mirror-repo;
  git fetch;
  GIT_WORK_TREE=/path/to/production-repo git checkout -f master

Related articles

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.