Configure GitServer in RedHatLinux

Source: Internet
Author: User
After trying to use RedHatLinux to configure gitserver over the past few days, we should first configure EPEL. Otherwise, we should download the source code compilation (if it is hard to do so). For details about EPEL configuration, refer to idea.

I tried to use RedHat Linux to configure git server over the past few days, but it was still quite smooth.

Configure EPEL first, Otherwise it is necessary to download the source code compilation (relatively tossing, forget), EPEL configuration see http://www.linuxidc.com/Linux/2012-04/58309.htm

Then configure the git server.

1. Install git-core

  1. Yum install git-core

2. initialize a repository

  1. [Root @ bogon first] # git init -- bare myprj // The directory where the project is stored. myprj indicates the project name.
  2. Initialized empty Git repository in/home/xfx-git/first/myprj/
PS; Specify -- bare. Currently, only objects under. git/is available in repository, but no real files are available. Generally on the Server side

3. initialize and submit the project

After repository is initialized, we need to createMaster branchTo be cloned by normal git

  1. [Root @ bogon first] # cd myprj/
  2. [Root @ bogon myprj] # mkdir initial. commit
  3. [Root @ bogon initial. commit] # git init
  4. Initialized empty Git repository in/home/xfx-git/first/myprj/initial. commit/. git/
  5. [Root @ bogon initial. commit] # git remote add origin/home/xfx-git/first/myprj/
  6. [Root @ bogon initial. commit] # touch Readme
  7. [Root @ bogon initial. commit] # git add Readme
  8. [Root @ bogon initial. commit] # git commit-m "inner commit"
  9. [Master (root-commit) 5b6e14d] in‑commit
  10. Committer: root
  11. Your name and email address were configured automatically based
  12. On your username and hostname. Please check that they are accurate.
  13. You can suppress this message by setting them explicitly:
  14. Git config -- global user. name "Your Name"
  15. Git config -- global user. email you@example.com
  16. After doing this, you may fix the identity used for this commit:
  17. Git commit -- amend -- reset-author
  18. 0 files changed, 0 insertions (+), 0 deletions (-)
  19. Create mode 100644 Readme
  20. [Root @ bogon initial. commit] # git push origin master
  21. Counting objects: 3, done.
  22. Unpacking objects: 100% (3/3), done.
  23. Writing objects: 100% (3/3), 203 bytes, done.
  24. Total 3 (delta 0), reused 0 (delta 0)
  25. To/home/xfx-git/first/myprj/
  26. * [New branch] master-> master
4. The repository is activated and can be used normally.
  1. [Root @ bogon myclient] $ git clone/home/xfx-git/first/myprj
  2. Cloning into 'myprj '...
  3. Done.
  4. [Root @ bogon myclient] $ cd myprj
  5. [Root @ bogon myprj] $ vim Readme
  6. [Root @ bogon myprj] $ git commit-m "modify readme" Readme
  7. [Master 1bf69b4] modify readme
  8. 1 files changed, 1 insertions (+), 0 deletions (-)
  9. [Root @ bogon myprj] $ git push
  10. Counting objects: 5, done.
  11. Writing objects: 100% (3/3), 247 bytes, done.
  12. Total 3 (delta 0), reused 0 (delta 0)
  13. Unpacking objects: 100% (3/3), done.
  14. To/home/xfx-git/first/myprj
  15. 032dad8 .. 1bf69b4 master-> master
5. Use of git. Several Common git methods are reproduced here.

(1) SSH
You are familiar with the SSH protocol, as long as your Server can log on to it through ssh. Assume that your Server can log on remotely through ssh. Let's see how to clone Git Repository from the Server:
[Lgao @ lgao myclient] $Git clone lgao@10.66.14.143: git_repos/myprj from_remote
Cloning into 'from _ remote '...
Lgao@10.66.14.143's password:
Remote: Counting objects: 3, done.
Remote: Total 3 (delta 0), reused 0 (delta 0)
Grouping objects: 100% (3/3), done.
That is to say, you can clone the code after creating an account for a user on the Server.Specific chmod.html 'target = '_ blank'> the permission settings are the same as those in Linux. Generally, you can specify a new group with a group of repositories. After adding a new user to the group, you can have the corresponding read and write permissions.
Another method is to submit the public key to the Server to obtain access and submission permissions, without the need to create a user. Details are not discussed in this article.
(2) Git
This Protocol is generally only read-only.
Step 1 install git-daemon:
[Root @ lgao ~] #Yum install git-daemon
Start git-daemon:
[Lgao @ lgao initial. commit] $Git daemon -- base-path =/home/lgao/sources/my_own/repositories -- export-all
Create the git-daemon-export-OK file in your project:
[Lgao @ lgao repositories] $Cd myprj
[Lgao @ lgao myprj] $Touch git-daemon-export-OK
Now you can clone repository through the Git protocol:
[Lgao @ lgao test] $Git clone git: // lgao.nay.redhat.com/myprj
Cloning into 'myprj '...
Remote: Counting objects: 6, done.
Remote: Compressing objects: 100% (2/2), done.
Remote: Total 6 (delta 0), reused 0 (delta 0)
Grouping objects: 100% (6/6), done.
(3) HTTP
This Protocol is generally only read-only. The GitWeb package provides CGI, which can be deployed on any server that supports static web Services. We also take the most common Apache as an example:
Version:
Httpd: Apache/2.2.21 (Fedora)
Git: git version 1.7.7.5
GitWeb: 1.7.7.5-1. fc16
Install Httpd and gitweb:
[Lgao @ lgao initial. commit] $Yum install httpd gitweb
Modify/etc/gitweb. conf:
[Lgao @ lgao repositories] $Vim/etc/gitweb. conf
Add:
Our $ projectroot = "/home/lgao/sources/my_own/repositories ";
Create a Link file in the directory where httpd DocumentRoot is located:
[Root @ lgao DCIM] #Cd/var/www/html
[Root @ lgao html] #Ln-s/home/lgao/sources/my_own/repositories/git
[Root @ lgao html] #Chown-R 777 git
Restart httpd:
[Root @ lgao httpd] #Service httpd restart
Restarting httpd (via systemctl): [OK]

PS: the access URL here is 10.0.61.61/git. You can access it by modifying the previous redhat server IP address.

For more information about RedHat, see RedHat topic page http://www.linuxidc.com/topicnews.aspx? Tid = 10

Related Article

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.