Install gitolite3 in Linux server
- install gitolite3 in root
sudo apt update
sudo apt upgrade
sudo apt install gitolite3
- add user git-admin, git in root
adduser --system --shell /bin/bash --group --disabled-password --home /home/git git
adduser --system --shell /bin/bash --ingroup git --disabled-password --home /home/git-admin git-admin
- make key for git-admin
su -l git-admin
ssh-keygen -t rsa
- assign git-admin to git server in root
cp /home/git-admin/.ssh/id_rsa.pub /home/git/git-admin.pub
chown git.git /home/git/git-admin.pub
- initialize gitolite in root
su -l git
git clone https://github.com/sitaramc/gitolite.git
/home/git/gitolite/install
/home/git/gitolite/src/gitolite setup -pk git-admin.pub
ls -al ./repositories/
total 0
drwx—— 9 git git 4096 Jul 5 09:41 .
drwxr-xr-x 8 git git 4096 Jul 5 09:50 ..
drwx—— 8 git git 4096 Jul 5 09:41 gitolite-admin.git
drwx—— 7 git git 4096 Jul 5 09:41 testing.git
su -l git-admin
git clone git@localhost:gitolite-admin.git
Cloning into ‘gitolite-admin’…
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 6 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (6/6), done.
tree
.
└── gitolite-admin
├── conf
│ └── gitolite.conf
└── keydir
└── git-admin.pub
3 directories, 2 files
Add Users for git
- make id_rsa, id_rsa.pub files for each user in Client (Windows/Linux)
ssh-keygen -t rsa
scp username/homedirectory/.ssh/id_rsa.pub git-admin@server_ip:/home/git-admin/gitolite-admin/keydir/username.pub
- check username.pub file in server
ls -al /home/git-admin/gitolite-admin/keydir
drwxr-xr-x 2 git-admin git 4096 Jun 7 15:15 ./
drwxr-xr-x 5 git-admin git 4096 Jun 7 12:17 ../
-rw-r–r– 1 git-admin git 399 Jun 7 12:17 git-admin.pub
-rw-r–r– 1 git-admin git 397 Jun 7 12:19 jenkins.pub
-rw-r–r– 1 git-admin git 574 Jun 7 13:16 MIND.pub
-rw-r–r– 1 git-admin git 574 Jun 7 14:29 user.pub
- push git in git-admin
su -l git-admin
git add keydir
git commit -m 'Add user username'
git push origin master
- if you error for user email and name
git config --global user.email "git-admin@example.com"
git config --global user.name "git-admin"
Add Repository
- make new repository in root server
su -l git-admin
vi /home/git-admin/gitolite-admin/conf/gitolite.conf
repo gitolite-admin
RW+ = git-admin
repo testing
RW+ = @all
repo new_repository_name
RW+ = @all
- push git in git-admin
git add conf/gitolite.conf
git commit -m 'Add new repo repo_name'
git push origin master
remote: Initialized empty Git repository in /home/git/repositories/new_repository_name.git/ To localhost:gitolite-admin.git 2afea3f..0435017 master -> master
ls -al /home/git/repositories/
total 0
drwx—— 9 git git 4096 Jul 5 09:41 .
drwxr-xr-x 8 git git 4096 Jul 5 09:50 ..
drwx—— 8 git git 4096 Jul 5 09:41 gitolite-admin.git
drwx—— 8 git git 4096 Jul 5 09:56 new_repository_name.git
drwx—— 7 git git 4096 Jul 5 09:41 testing.git
- username can use git repository
git clone ssh://git@server_ip/new_repository_name.git or git@server_ip/new_repository_name.git