Gitolite: Difference between revisions
Line 7: | Line 7: | ||
=== In your workstation set up new public keys === | === In your workstation set up new public keys === | ||
Running this command will create a new pair of private and public key. | Running this command will create a new pair of private and public key. | ||
{{Cmd|ssh-keygen -N '' -f | {{Cmd|ssh-keygen -N '' -f ~/.ssh/id_rsa}} | ||
Create a copy of the public key. | Create a copy of the public key. | ||
{{Cmd|cp | {{Cmd|cp ~/.ssh/id_rsa.pub ~/.ssh/YOUR_USERNAME.pub}} | ||
Send the public key to your server by running the command shown below. | Send the public key to your server by running the command shown below. | ||
{{Cmd|scp | {{Cmd|scp ~/.ssh/YOUR_USERNAME.pub root@YOUR_SERVER_DOMAIN_OR_IP:/var/lib/git/YOUR_USERNAME.pub}} | ||
=== In your server set up Gitolite === | === In your server set up Gitolite === |
Revision as of 07:51, 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.
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 ${HOME}/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
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 repository, create one
Create a dotfiles directory.
mkdir ${HOME}/dotfiles/
Initialize a git repository in the dotfiles directory.
git -C ${HOME}/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 ${HOME}/dotfiles/ remote add origin git@YOUR_SERVER_DOMAIN_OR_IP:YOUR_GIT_REPO
Add some files to your new repository.
echo "hello world" > ${HOME}/dotfiles/testfile
git -C ${HOME}/dotfiles/ add ${HOME}/dotfiles/testfile
Create a commit.
git -C ${HOME}/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 ${HOME}/dotfiles/ push --set-upstream origin master