use any ssh server as a git server
# YOUR_REPO - reposytory name
# SHORT_REMOTE_NAME - short server (remote) name in local git config
# REMOTE_USERNAME - username in server side
# /home/REMOTE_USERNAME/ path on server (can be anything, provided that the user on the server has the right to write to this path)
# create local repo
mkdir /tmp/YOUR_REPO
cd /tmp/YOUR_REPO
git init
# create remote repo (on server)
ssh -p PORT REMOTE_USERNAME@DOMAIN_OR_IP "git init --bare /home/REMOTE_USERNAME/YOUR_REPO.git"
# add remote (server) in local repo
git remote add SHORT_REMOTE_NAME ssh://REMOTE_USERNAME@DOMAIN_OR_IP:PORT/home/REMOTE_USERNAME/YOUR_REPO.git
# add & commit changes in local repo
nano ./test
git add test
git commit -a -m 'test'
# first time push to server must be with set upstream (default remote)
git push --set-upstream SHORT_REMOTE_NAME master
# another push to server can be without set upstream
git push
Содержание