Skip to content

Instantly share code, notes, and snippets.

@Verron
Last active August 17, 2018 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Verron/c579abdf5e684d81b12d7ecc354a3a6e to your computer and use it in GitHub Desktop.
Save Verron/c579abdf5e684d81b12d7ecc354a3a6e to your computer and use it in GitHub Desktop.
Setup server to push to from another server or laptop
Push code out to servers from your laptop or another server.
Follow setup.md then test it out with using.md

Setup server to receive

Where you are pushing from (sending server/laptop)

git remote add

Example:

SSH

git remote add production <user>@<host>:/path/to/git/folder

Where you are pushing to (receiving server)

Go to folder

Type

git init --bare

Add to hooks/post-receive

#!/bin/sh
GIT_WORK_TREE=/path/to/git/folder git checkout -f
# Using PHP Composer?
composer install
# Worried about permissions?
chown <user>:<group> /path/to/git/folder -R
# Do what it takes to automate push in this file or in another hooks/ script

Deploy to servers using git push

Pushing branch

git push

Example

git push production master

Pushing tags

git push ^{}:master

Example

git push production v1.0.5^{}:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment