Login to your server

mkdir /var/repo && cd /var/repo
mkdir sample.com.git & cd sample.com
git init --bare 

–bare means that our folder will have no source files, just the version control.

cd /var/repo/sample.com.git
cat > post-receive

git --work-tree=/var/www/domain.com --git-dir=/var/repo/site.git checkout -f

When you finish typing, press ‘control-d’ to save.

chmod +x post-receive


cd to_your_working_directory
mkdir sample.com && cd sample.com
git init
git remote add prod ssh:/IP-ADDRESS/var/repo/sample.com.git

Push to the server is as simple as

git push prod master