Gitolite: Difference between revisions

From Alpine Linux
mNo edit summary
(Overhaul of the Gitolite guide because it was obsolete.)
Line 1: Line 1:
== Manual Setup ==
== Setting up Gitolite ==
Install the package that contains Gitolite.
{{Cmd|apk add gitolite git}}


The installation of [http://sitaramc.github.com/gitolite/ Gitolite] is relatively easy on Alpine Linux. Below is the method to install Gitolite on a user account.
=== In your workstation set up new public keys ===
# Log into root user
Running this command will create a new pair of private and public key.
# {{Cmd|apk add perl bash git nano}}
{{Cmd|ssh-keygen -N '' -f "${HOME}/.ssh/id_rsa"}}
# {{Cmd|adduser -s /bin/bash -S git}}
Create a copy of the public key.
# {{Cmd|su - git}}
{{Cmd|cp ${HOME}/.ssh/id_rsa.pub ${HOME}/.ssh/YOUR_USERNAME.pub}}
# On your local machine make a ssh key {{Cmd|ssh-keygen -t myname.pub}}
Send the public key to your server by running the command shown below.
# Next, run {{Cmd|scp ~/.ssh/myname.pub git@example.com:myname.pub}} on your local machine
{{Cmd|scp ${HOME}/.ssh/YOUR_USERNAME.pub root@YOUR_SERVER_IP:/var/lib/git/YOUR_USERNAME.pub}}
# 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 this, add the path it gives you in a new file called <code>.bash_profile</code>.
# {{Cmd|nano /home/git/.bash_profile}}
# Add the line and save - ''Ctrl+X''.
# Logout and then log 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, commit them, and push them back to the server.


I'm a brand new Alpine user and was able to get it working using the above instructions. Hope this will help someone else!
=== In your server set up Gitolite ===
This command will setup gitolite using the public key you just sent to the server.
{{Cmd|su git -c "gitolite setup -pk /var/lib/git/YOUR_USERNAME.pub"}}
{{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.}}
 
=== In your workstation set up Gitolite ===
Clone the .git directory to administrate Gitolite outside a server.
{{Cmd|git clone git@${SERVERIP}:gitolite-admin}}
Use your favorite text editor and open the file ${HOME}/gitolite-admin/conf/gitolite.conf
{{Cmd|vim ${HOME}/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|${HOME}/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 ${HOME}/gitolite-admin/ commit -am "My new custom repository."}}
Push the changes to the server.
{{Cmd|git -C ${HOME}/gitolite-admin/" push}}
 
=== In your workstation, if you don't have a .git, create one ===
Initialize a .git
{{Cmd|git -C ${HOME} 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 ${HOME} remote add origin git@YOUR_SERVER_IP:YOUR_GIT_REPO}}
Add some files to your new repository.
{{Cmd|git -C ${HOME} add ${HOME}/.bashrc}}
Create a commit.
{{Cmd|git -C ${HOME} 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 ${HOME} push --set-upstream origin master}}


[[Category:Server]]
[[Category:Server]]
[[Category:Git]]
[[Category:Git]]

Revision as of 07:13, 20 August 2019

Setting up Gitolite

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 "${HOME}/.ssh/id_rsa"

Create a copy of the public key.

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

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

scp ${HOME}/.ssh/YOUR_USERNAME.pub root@YOUR_SERVER_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.

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

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.


In your workstation set up Gitolite

Clone the .git directory to administrate Gitolite outside a server.

git clone git@${SERVERIP}:gitolite-admin

Use your favorite text editor and open the file ${HOME}/gitolite-admin/conf/gitolite.conf

vim ${HOME}/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 ${HOME}/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 ${HOME}/gitolite-admin/ commit -am "My new custom repository."

Push the changes to the server.

git -C ${HOME}/gitolite-admin/" push

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

Initialize a .git

git -C ${HOME} 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 ${HOME} remote add origin git@YOUR_SERVER_IP:YOUR_GIT_REPO

Add some files to your new repository.

git -C ${HOME} add ${HOME}/.bashrc

Create a commit.

git -C ${HOME} 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 ${HOME} push --set-upstream origin master