Easy and convenient git's first step

Source: Internet
Author: User

Now git is already overwhelming. If you don't have to try again, it will really be out. So I decided to apply git to the new project. After one afternoon and another two hours, we finally got it done. It is really easy to find git, which is beyond my expectation. But since it is simple, why is it difficult? This is because it is really difficult to turn from the ideas and usage habits of CVs and SVN.

Question 1: What is the GIT server version? How to install?

SVN has a svnserver that can be directly installed through Yum or apt-get. What is the GIT server version? Through Yum search git, only gitolite and gitosis seem to have a relationship with the server, and gitosis is now gradually replaced by gitolite. Gitolite installation instructions are found on GitHub: Repository.

Install git before installing gitolite

# yum -y install git

The gitolite Installation Process on the server is as follows:

1. Log On As the root user and create a new git user. The user's home directory will be used to store git repository. This user name is not necessarily called git and can be specified at will, but git is usually used. You can see the role of this account at a glance.

# useradd -d /home/git git# passwd git

2. log on to the server as git and install gitolite.

$ git clone https://github.com/sitaramc/gitolite

The above is to first get gitolite from GitHub, In the addressHTTPSYou can also replace itHTTPOrGit. Run the following command to complete the installation:

$ gitolite/install -ln

The above command requires that the/home/git/bin directory exists, and the directory is in the $ PATH variable of the GIT account.
So far the installation has come to an end, and the next step is the configuration.

Question 2: How to configure gitolite?

Before using SVN, Apache needs to be configured for HTTP access. So does gitolite need to be configured? Of course, the answer is yes.

The premise is that the SSH public key should be generated on the Administrator (who will be responsible for maintaining git later). I have putty on win7 and named it kmeng. pub: upload it to the git home directory on the server. Run the following command:

$ gitolite setup -pk kmeng.pub

Unexpectedly, we got a bunch of exception information:

Fatal: have errors but logging failed!

Open log failed: no such file or directory
Die kmeng. Pub must have exactly one line

I consulted my colleagues who used it before. It turns out that it was generated through putty and the format is incorrect. You need to use the following command to convert the OpenSSH format:

$ ssh-keygen -i -f kmeng_o.pub > kmeng.pub$ gitolite setup -pk kmeng.pub

After the command is executed, the repositories directory is generated in the/home/git directory. Kmeng serves as the Administrator name and is also the first user of git repository.

Now the configuration is complete, and the following is the usage.

Question 3: Since the installation and configuration are complete, how can I create a new project?

This is a little unexpected. Gitolite also adopts the Common repository mode for server maintenance. First, clone (equivalent to SVN checkout) A gitolite-Admin project on the Administrator's local computer:

git clone git@192.168.0.100:gitolite-admin

Locally, A gitolite-Admin directory is checked out, which contains the conf and keydir folders. conf stores the user's access permissions for different repository, keydir is the user's public key. Now it only contains kmeng. pub.

The method for creating a repository is really unexpected. First, edit gitolite. conf in conf and change it:

repo gitolite-admin myapp       RW+        =        kmengrepo testing       RW+        =        @all

The MyApp is newly added, and then the new repository is created by executing the GIT commit and push commands.

$ git commit -a$ git push

Log on to the server, view/home/git/repositories, and find a directory of MyApp. Git.

It will be too simple to use git in the future.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.