Skip to content

Instantly share code, notes, and snippets.

@hoyin258
Last active July 7, 2022 21:34
Show Gist options
  • Save hoyin258/f59a8702d3de9ed6b3f5 to your computer and use it in GitHub Desktop.
Save hoyin258/f59a8702d3de9ed6b3f5 to your computer and use it in GitHub Desktop.
VPS Git Server Setup

Create repository

VPS:

su
cd /var/www/
mkdir site
cd /var
mkdir repo && cd repo
mkdir site.git && cd site.git
git init --bare
cd hooks
cat > post-receive
chmod +x post-receive
#!/bin/sh
git --work-tree=/var/www/site --git-dir=/var/repo/site.git checkout -f

(Press Ctrl+D to exit)

Local

mkdir project
cd project
git init
touch file
git add .
git commit - m "Add project"
git remote add beta ssh://[email protected]:port/var/repo/site.git
git push remote master

Permission Problem

ssh [email protected]:port
cd /var/repo/site.git

sudo chmod -R g+ws *
sudo chgrp -R mygroup *

git config core.sharedRepository true
@alenpaulvarghese
Copy link

Thanks for this clean solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment