Gitolite: Difference between revisions

From Alpine Linux
m (category added)
 
(25 intermediate revisions by 4 users not shown)
Line 1: Line 1:
The installation of [http://sitaramc.github.com/gitolite/ gitolite] is relatively easy on alpine Linux. Bellow is the method to install gitolite on a user account.
[https://gitolite.com/ Gitolite] is a wrapper around a base git installation which facilitates the secure management of project repositories and of the user privileges governing access to those repositories.  
# Log into root user
# {{Cmd|apk add perl bash git nano}}
# {{Cmd|adduser -s /bin/bash -S git}}
# {{Cmd|su - git}}
# On your local machine make a ssh key {{Cmd|ssh-keygen -t myname.pub}}
# Next run {{Cmd|scp ~/.ssh/myname.pub git@example.com:myname.pub}} on your local machine
# On the remote machine type {{Cmd|git clone git://github.com/sitaramc/gitolite}}
# {{Cmd|gitolite/src/gl-system-install}}
# you will receive an error message, to fix add the path it gives you in a new file called .bash_profile. {{Cmd|nano /home/git/.bash_profile}}
# add the line and save Ctrl+X
# logout and then back into the git user
# {{Cmd|gl-setup myname.pub}}
# on your local machine you can now {{Cmd|git clone git@example.com:gitolite-admin}}
# on your local machine you can now edit your config files then commit them and push them back to the server


Im a brand new alpine user and was able to get it working using the above instructions, hope this will help someone else!
== Installation ==
Install the package that contains Gitolite.
{{Cmd|apk add gitolite git}}


[[Category:Networking]]
=== In your workstation set up new public keys ===
Running this command will create a new pair of private and public key.
{{Cmd|ssh-keygen -N "" -f ~/.ssh/id_rsa}}
Create a copy of the public key.
{{Cmd|cp ~/.ssh/id_rsa.pub ~/.ssh/${YOUR_USERNAME}.pub}}
Send the public key to your server by running the command shown below.
{{Cmd|scp ~/.ssh/${YOUR_USERNAME}.pub root@${YOUR_SERVER_DOMAIN_OR_IP}:/var/lib/git/${YOUR_USERNAME}.pub}}
 
=== In your server set up Gitolite ===
This command will setup Gitolite using the public key you just sent to the server.
{{Warning|There is no need to add password to the default git account that was created automatically by the system. We run git via su git.}}
{{Cmd|su git -c "gitolite setup -pk /var/lib/git/${YOUR_USERNAME}.pub"}}
 
=== In your workstation set up Gitolite ===
In your workstation clone the .git directory anywhere you want (preferably your home directory) to administrate Gitolite outside a server.
{{Cmd|git clone git@${YOUR_SERVER_DOMAIN_OR_IP}:gitolite-admin ~/gitolite-admin}}
Use your favorite text editor and open the file ~/gitolite-admin/conf/gitolite.conf
{{Cmd|vim ~/gitolite-admin/conf/gitolite.conf}}
Add to that file the name of a git repository which Gitolite will manage. It should look something like this:
{{Cat|~/gitolite-admin/conf/gitolite.conf|<nowiki>
repo gitolite-admin
RW+ = YOUR_USERNAME
repo testing
RW+ = @all
repo YOUR_GIT_REPO
RW+ = YOUR_USERNAME
</nowiki>
}}
Make commit of what you just changed.
{{Cmd|git -C ~/gitolite-admin/ commit -am "My new custom repository."}}
Push the changes to the server.
{{Cmd|git -C ~/gitolite-admin/ push}}
 
=== In your workstation, if you don't have a git repository, create one ===
Create a dotfiles directory.
{{Cmd|mkdir ~/dotfiles/}}
Initialize a git repository in the dotfiles directory.
{{Cmd|git -C ~/dotfiles/ init}}
We will add the remote for this new .git. In this case we point the server in which Gitolite was installed, and the repository name we sent before by pushing data via gitolite-admin.
{{Cmd|git -C ~/dotfiles/ remote add origin git@${YOUR_SERVER_DOMAIN_OR_IP}:${YOUR_GIT_REPO} }}
Add some files to your new repository.
{{Cmd|echo "hello world" > ~/dotfiles/testfile}}
{{Cmd|git -C ~/dotfiles/ add ~/dotfiles/testfile}}
Create a commit.
{{Cmd|git -C ~/dotfiles/ commit -am "This is my first commit."}}
Push the files to the server. In this case it's being pushed to the server in which Gitolite was installed.
{{Cmd|git -C ~/dotfiles/ push --set-upstream origin master}}
 
[[Category:Server]]
[[Category:Git]]

Latest revision as of 08:05, 10 September 2019

Gitolite is a wrapper around a base git installation which facilitates the secure management of project repositories and of the user privileges governing access to those repositories.

Installation

Install the package that contains Gitolite.

apk add gitolite git

In your workstation set up new public keys

Running this command will create a new pair of private and public key.

ssh-keygen -N "" -f ~/.ssh/id_rsa

Create a copy of the public key.

cp ~/.ssh/id_rsa.pub ~/.ssh/${YOUR_USERNAME}.pub

Send the public key to your server by running the command shown below.

scp ~/.ssh/${YOUR_USERNAME}.pub root@${YOUR_SERVER_DOMAIN_OR_IP}:/var/lib/git/${YOUR_USERNAME}.pub

In your server set up Gitolite

This command will setup Gitolite using the public key you just sent to the server.

Warning: There is no need to add password to the default git account that was created automatically by the system. We run git via su git.


su git -c "gitolite setup -pk /var/lib/git/${YOUR_USERNAME}.pub"

In your workstation set up Gitolite

In your workstation clone the .git directory anywhere you want (preferably your home directory) to administrate Gitolite outside a server.

git clone git@${YOUR_SERVER_DOMAIN_OR_IP}:gitolite-admin ~/gitolite-admin

Use your favorite text editor and open the file ~/gitolite-admin/conf/gitolite.conf

vim ~/gitolite-admin/conf/gitolite.conf

Add to that file the name of a git repository which Gitolite will manage. It should look something like this:

Contents of ~/gitolite-admin/conf/gitolite.conf

repo gitolite-admin RW+ = YOUR_USERNAME repo testing RW+ = @all repo YOUR_GIT_REPO RW+ = YOUR_USERNAME

Make commit of what you just changed.

git -C ~/gitolite-admin/ commit -am "My new custom repository."

Push the changes to the server.

git -C ~/gitolite-admin/ push

In your workstation, if you don't have a git repository, create one

Create a dotfiles directory.

mkdir ~/dotfiles/

Initialize a git repository in the dotfiles directory.

git -C ~/dotfiles/ init

We will add the remote for this new .git. In this case we point the server in which Gitolite was installed, and the repository name we sent before by pushing data via gitolite-admin.

git -C ~/dotfiles/ remote add origin git@${YOUR_SERVER_DOMAIN_OR_IP}:${YOUR_GIT_REPO}

Add some files to your new repository.

echo "hello world" > ~/dotfiles/testfile

git -C ~/dotfiles/ add ~/dotfiles/testfile

Create a commit.

git -C ~/dotfiles/ commit -am "This is my first commit."

Push the files to the server. In this case it's being pushed to the server in which Gitolite was installed.

git -C ~/dotfiles/ push --set-upstream origin master