environment:
Ubuntu server 14.04.1 、Git 1.9.1 gitolite3
The introduction of Git will not be introduced here. If you are interested, you can search the Internet by yourself.
The following describes how to install the Git server gitolite, as well as how to create a repository, add users, etc. This article will not introduce too many commands of Git itself, because I haven't played it clearly yet. When I play it clearly, I will write it. Articles are shared.
1 Build ubuntu environment
I am using ubuntu installed on the virtual machine here. I am using 14.04. I used 13.04 at the beginning, but some packages are not available, so I use 14.04 for all. (I'm a novice for Linux , why there is no possibility that it is not set correctly, don't spray)
2 Install Git
First of all, we need to install Git, ubuntu provides a very convenient installation tool, apt-get, so we use this tool to install, enter the following command in the command line (the server version is the command line, if it is the desktop version, search and enter the command line by yourself ):
sudo apt-get update
This command is used to update the resources of the software that apt-get can install
sudo apt-get install git
This command is used to install Git (the diamond below is garbled)
3 Install openssh-server
sudo apt-get install openssh-server
ssh access requires the use of openssh-server
4 Add administrative users
Add user git (it can also be other user names, here is just for easy memory), this user is used to manage git, including the creation of warehouses, the addition of git users, etc.
sudo adduser --system --shell /bin/bash --group git
In some systems, only users in a specific user group (such as the ssh user group) can log in through the SSH protocol, which requires adding the newly created git user to the ssh user group.
sudo adduser git ssh
set password
passwd git
5 Generate ssh key
Git needs to use ssh access, so you need to generate a set of ssh keys. As for the detailed introduction of ssh access, you can search for it yourself.
Switch to git user
go water
ssh-keygen
cd .ssh
cp id_rsa.pub authorized_keys
6 Install gitolite
under git user
mkdir bin creates a bin directory for installing gitolite
Clone gitolite from the remote
git clone git: //github.com/sitaramc/gitolite
Execute the following command to install
~/gitolite/install -to ~/bin
mv ~/.ssh/authorized_keys ~/git.pub
~/bin/gitolite setup -pk ~/git.pub
If the following indicates success:
7 View the default repository
Or ssh [email protected] under the git user
The following appears:
hello git, this is git@linux-dev running gitolite3 v3.5.2-4-g62fb317 on git1.8.1.2
RW gitolite-admin
RW testing means
gitolite works normally
. After successful installation, gitolite will automatically generate two repositories, one for testing. git is used for testing , and another gitolite-admin is used to manage the configuration repository of gitolite.
Clone gitolite-admin.git to the local, note: it is still under the git user, because currently only the git user has read and write permissions to it.
git clone [email protected]:gitolite-admin
The gitolite-admin directory will appear under the current directory.
8 Add git user
It is necessary to generate a public key file for the user to be added. The test I did here under the mac is the same as the ssh key generated by git in linux. In windows, it seems that a tool msysgit needs to be used. For the generated pair of files, xxx.pub needs to be modified to the name of the user to be added. For example, the user name we want to add is mxy, and id_rsa.pub needs to be modified to mxy.pub. Use the following command to copy to the gitolite-admin/keydir directory:
scp <user>.pub git@ip:gitolite-admin/keydir Copy the pub public key to the gitolite-admin repository
Then check whether the corresponding file already exists in the corresponding directory of the git server.
At this point, the user has only added a part, and the real addition is complete and continue to look down.
9 Add warehouse
Open the gitolite-admin/conf/gitolite.conf file
Modify it to the following content (vi command to search by yourself, i, esc, :wq are basically used here)
The above repo represents the creation of a demo warehouse (there are many ways to create it, here I only introduce this one), the following RW represents read and write, and there are other keywords, search by yourself. The representation after the equal sign is the permission for this repository, and multiple users are separated by spaces.
10 Push configuration to gitolite server
When you go to step 9, do you think it is over, but it is not yet, because our gitolite-admin is cloned, these configurations are only saved in my local, so we also need to push it to gitolite on the server before it will take effect.
Execute the following command in the gitolite-admin directory
git add .
git commit -m "This is the commit information, used to indicate the explanation of this commit, you can write it casually"
At this step, the following errors may occur, we need to configure the submission information
The solution is as follows (of course the final configuration needs to be filled in according to your actual situation):
The command git push origin master is to push to the server. The above two are only local submissions. You can understand the local submissions by studying git well.
1. master is the main branch, and some other branches can be built for development.
2. git push origin master means uploading the local current branch code to the master branch. git push is to upload all local branch code to the corresponding remote branch.
1 1 Test whether the build is successful
Use the added user to clone the demo library. If the clone is successful, it means that there is no problem. The user I configured is mxy, so my command line is as follows:
Above [email protected], this git refers to the user who manages git, and the latter ip refers to the ip of the git server. If we can democlone it, it means success