How to move a local Git repository to a shared server

Tagged git  Languages apacheconf

Short version:

# On server
git init --bare /var/www/xyz/frontend.git

# On local
git remote add server [email protected]:/var/git/frontend.git
git push server master

Longer version:

# On local computer
git clone --bare . xxx.git
tar cvf xxx.tar xxx.git
scp xxx.tar

# On remote server
cd /var/git/repositories
tar xvf /tmp/xxx.tar

# On local computer
git remote add origin ssh://[email protected]/var/git/repositories/xxx.git
git push origin master