Skip to content

Instantly share code, notes, and snippets.

@petriichuk
Last active December 18, 2016 08:58
Show Gist options
  • Save petriichuk/971f40f9bd04c33cce28e56aafb61e8a to your computer and use it in GitHub Desktop.
Save petriichuk/971f40f9bd04c33cce28e56aafb61e8a to your computer and use it in GitHub Desktop.
ServerConfigurationCommands(Ubuntu 16.4)
https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps
#REMOTE SERVER
#install
sudo apt-get install git-core
#copy your username and email in the gitconfig file
sudo nano ~/.gitconfig
git config --global user.name "NewUser"
git config --global user.email newuser@example.com
#show your settings
git config --list
#creatingWebRepoForDeploy
cd ~/
mkdir repo && cd repo
mkdir site.git && cd site.git
#createRepoWithoutSourceFiles
git init --bare
#createHook
cd hooks
nano post-receive
#PutThereNextContent
#!/bin/sh
git --work-tree=/var/www/domain.com --git-dir=/var/repo/site.git checkout -f
#giveItExecutePerm
chmod +x post-receive
#LOCAL
cd ~/projects/
mkdir project && cd project
git init
#AddRemote
git remote add live ssh://user@mydomain.com/home/user/repo/site.git
#FirstCommit
git add .
git commit -m "Init"
#FirsForcePushToLiveRemote
git push -f live master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment