Source environment will be built recently. There was no ready-made environment, so we had to build it ourselves. Based on Ubuntu 14.04. Other versions of Ubuntu are theoretically available. Follow-up in collating again about Git Build under Server Android Source version management.
Ad locum git The benefits of version management are not covered much. You can Baidu by yourself. Here is a more detailed explanation of the construction process. It is convenient for you to build your own Git version management server faster. Once the configuration is completed, the Ubuntu login interface will have one more git user logged in. If you find it obscure, you can refer to my previous article. Ubuntu 14.10 login screen hides other user login windows . Let's not say much. Let's start our construction journey.
First, create Git users.
1. Install git-core, Python-setuptools,openssh-server,openssh-client(python - setuptools is mainly used to install gitosis. The latter two softwares are mainly designed to facilitate the use of Putty to log directly into the server.
sudo apt-get install git-core python-setuptools openssh-server openssh-client
- 1
- 1
2. Create the initial password of GIT user and initial git user
sudo useradd -m git
sudo passwd git
- 1
- 2
- 1
- 2
3. Create directories for git users
sudo mkdir /home/repo
sudo chown git:git /home/repo
- 1
- 2
- 1
- 2
2. Install Gitosis software.
1. Install Gitosis. (For unified management, I'll put several important files in the Tools directory I built to install and configure.)
mkdir Tools
cd Tools
git clone git://eagain.net/gitosis
(If the clone fails, use the following address)
git clone https://github.com/res0nat0r/gitosis.git
cd gitosis/
sudo python setup.py install
(switch to git Users)
su git
(Soft Link Directory)
ln -s /home/repo /home/git/repositories
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
2. Generate administrator ssh public key and copy it to server.
(Here I use the server directly as an administrator, using the same principles as other servers)
ssh-keygen -t rsa
(Just return directly.
cp /home/XXX/.ssh/id_rsa.pub /tmp
(Use as much as possible git User copy, to prevent the next initialization can not read the public key.)
- 1
- 2
- 3
- 4
- 1
- 2
- 3
- 4
Other users, as administrators, can copy public keys directly to servers with USB disks or directly through commands.
scp .ssh/id_rsa.pub git@<ServerIP>:/tmp
(This method is used directly. git User copy.ServerIPFor youGitThe server ip. )
(Such as: scp .ssh/id_rsa.pub git@192.168.1.102:/tmp)
- 1
- 2
- 3
- 1
- 2
- 3
3. Initialize Gitosis so that your administrator's public key takes effect (on the Git server).
sudo -H -u git gitosis-init < /tmp/id_rsa.pub
- 1
- 1
3. Configure Gitosis and build the first version Library of Git.
1. Clone the Gitosis configuration library using the administrator machine (whose public key is uploaded from the front is the administrator, and can be added later.)
git clone git@localhost:gitosis-admin.git
- 1
- 1
2. Establishing "test.git" version Library in server
(GIt version libraries are unified in the / home/git/repositories directory, and folders must end with ".git")
(switch to git Users)
su git
(Establishing Version Library“ test.git")
cd ~/repositories
mkdir test.git
(Initialization test.gitVersion Library)
cd test.git
git init --bare
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
3. Configure the version Library of "test.git" in the administrator machine.
cd gitosis-admin/
(gitosis.confFor configuration files, keydir Public Key Folder)
vim gitosis.conf
- 1
- 2
- 3
- 1
- 2
- 3
Configuration information submitted after configuration
The command of public key must be the same as the name of public key, as follows: the name of your public key is next, and then the name of the public key is XXX.pub.)
git add gitosis.conf
git commit -am "Add“ test.git"Version library."
- 1
- 2
- 1
- 2
First submission will allow you to fill in your identity
git config --global user.email "Your mailbox@XXX.com"
git config --global user.name "Your Name"
(Fill in again commit Information)
git commit -am "Add“ test.git"Version library."
git push origin master
- 1
- 2
- 3
- 4
- 5
- 1
- 2
- 3
- 4
- 5
Four. test The first Git version library belongs to itself.
git clone git@localhost:test.git
cd test
echo "HelloWorld" > HelloWorld
git add HelloWorld
git commit -am "First submission record"
git push origin master
- 1
- 2
- 3
- 4
- 5
- 6
- 1
- 2
- 3
- 4
- 5
- 6
Reference Articles Configuring git server on ubuntu You can refer to this article for Git's read and write permission configuration.