Create Basic Self Hosted Remote Git Repo

Code

Create a basic self hosted remote git repository. For when you need something basic and private.
Repo interaction with be done via a git client over ssh.

Create Directory

This will be where all the projects will live.

sudo mkdir /code_repo
sudo mkdir /code_repo/project1

Set Directory Permissions

Obviously set it according to who will be connecting in. Here we will just give it an over-permissive 777.

cd /code_repo
sudo chmod -R 777 .

Insufficient privileges will result in an error similar to:

! [remote rejected] master -> master (unpacker error)

Init Repository

cd /code_repo/project1
sudo git init --bare .

Cloning Repo

This is done on the local/workstation. Not on the remote server

git clone user_name@remote_git_server.com:/code_repo/project1
Cloning into 'project1'…
 warning: You appear to have cloned an empty repository.

Note on Credentials

It is recommended to setup ssh keys so that you are not prompted for a password each time you commit.

  • https://git-scm.com/
,