Create system User
First, create a new system user, which will be used to connect repository to the server from client systems.
# sudo adduser git
|
Create Code Repository
Now create a git project code repository. This repository will be used as a remote repository by developers. First, we are creating a project directory. After that, I will create git repository named myfirstrepo.git inside project directory.
root@subhash:~# sudo su - git
git@subhash:~# mkdir projects
git@subhash:~# cd projects
git@subhash:~/projects# mkdir myfirstrepo.git
git@subhash:~/projects# cd myfirstrepo.git
|
Now initialize repository. Do not forget to use –bare keyword in command to create a bare repository.
git@subhash:~/projects/myfirstrepo.git# git --bare init
Initialized empty Git repository in /root/projects/myfirstrepo.git/
|
Now list files
root@subhash:~/projects/myfirstrepo.git# ls -l
drwxr-xr-x 2 root root 4096 Mar 6 07:28 branches
-rw-r--r-- 1 root root 66 Mar 6 07:28 config
-rw-r--r-- 1 root root 73 Mar 6 07:28 description
-rw-r--r-- 1 root root 23 Mar 6 07:28 HEAD
drwxr-xr-x 2 root root 4096 Mar 6 07:28 hooks
drwxr-xr-x 2 root root 4096 Mar 6 07:28 info
drwxr-xr-x 4 root root 4096 Mar 6 07:28 objects
drwxr-xr-x 4 root root 4096 Mar 6 07:28 refs
|
Clone Repository
Now you can make a clone of this repository from any clients system using the following command. This will ask for password of git user.
# git clone git@remote_server_location:projects/myfirstrepo.git
|