Skip to content

Instantly share code, notes, and snippets.

@pokisin
Last active May 8, 2017 17:10
Show Gist options
  • Save pokisin/57d98aa16f73b8113433cd3bac3b49ab to your computer and use it in GitHub Desktop.
Save pokisin/57d98aa16f73b8113433cd3bac3b49ab to your computer and use it in GitHub Desktop.
Instalar git en server

gl-setup id_rsa.pub

Install Git

Log into your Ubuntu server with your regular user account. We will be installing git from Ubuntu's default repositories:

~$ sudo apt-get install git-core

We now have git installed. We will want to configure a few things for git to operate properly.

Install Gitolite

Now that we have git set up correctly, we can install gitolite to manage user access to our repositories. Gitolite is also available in Ubuntu's default repositories. Install it with this command:

~$ sudo apt-get install gitolite

Gitolite manages its configuration through git! To set this up properly, we'll create a operating system user whose sole function is to interact with gitolite. The operating system user will be called git to make it easy for our collaborators to remember. We will not set a password so that it is only accessible through using the su command.

~$ sudo adduser --system --group --shell /bin/bash --disabled-password git

We now have a user called "git" that will handle gitolite configuration. We need to be able to access this user from a normal account. We will do this by configuring an SSH key associated with git administration.

Configure Gitolite

The next steps will take place back on our git server. Log back in with your normal user. We can log in with our "git" user to initialize gitolite with the public key we just transferred.

~$ sudo su - git

Now, we can set up gitolite with the following command:

~$ gl-setup /tmp/git-admin.pub

Hit ENTER to pull the configuration into your editor. Scan the contents to make sure the default configuration will meet your needs. You can always change it later. When you are finished, save and exit out of the file.

How To Administer Gitolite

Back on your local computer, you can begin administering gitolite. If you do not already have git installed on this computer, you need to install it with:

~$ sudo apt-get install git-core

First, we need to clone the gitolite information from our git server to our local machine:

~$ git clone git@git_server_IP_address:gitolite-admin

This will create a new directory called gitolite-admin within your current directory. Here, we can make changes to our access policies and then push those changes to the git server.

Now ssh into the server and create a project directory for Git. You can use the desired path for the repo.

git@server:~ $ mkdir -p /home/test/project-1.git

Then change to this directory:

~$ cd /home/test/project-1.git

Then create an empty repo:

~$ git init --bare

Initialized empty Git repository in /home/test/project-1.git

If there are other team members who want to work with the project they need to clone the repo on the server to their local machine:

git clone ssh://git@remote-server:PORT-SSH/home/test/project.git

👍 ♑

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment