Note while learning how to install a bare private git server.
Let's assume we have a server called gitserver.local
, with a normal user
bob
and a working SSH service. Log in with SSH via:
$ ssh bob@gitserver.local
Now install git-core
$ sudo apt-get install git-core -y
Now let's create a dedicate user called git
that will handle all the
repositories, change his password and log in as git
user:
$ useradd -m -d /home/git -s /bin/bash git
$ sudo passwd git
$ su - git
$ whoami
git
$ pwd
/home/git
Now let's assume that Alice want to save his git repository on our gitserver
.
So create a new folder for Alice and then a folder for her project:
$ mkdir -p alice/prj.git
$ cd alice/prj.git
Now initialize that folder with a bare git repo:
$ git init --bare
Now Alice is free to use his repository.
Installing and configuring git
on Alice machine:
$ sudo apt-get install git -y
$ git config --global user.name "Firstname Lastname"
$ git config --global user.email "your_email@example.com"
Alice want to push her project on our gitserver
. The first thing to do is
setting up her RSA keys and copy her public key to the server (that is
explained
here).
Now Alice can: (1) create a new git working directory and push the changes or
(2) clone the repository from gitserver
.
1
$ mkdir -p prj && cd prj
$ git init
$ git remote add git@gitserver.local:alice/prj.git
2
$ git clone git@gitserver.local:alice/prj.git prj && cd prj
Then she can work with her repository as usual:
$ echo "HELLO" >> README.md
$ git add . && git commit -m "added readme"
$ git push origin master