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
- Yum install git-core
2. initialize a repository
- [Root @ bogon first] # git init -- bare myprj // The directory where the project is stored. myprj indicates the project name.
- 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
- [Root @ bogon first] # cd myprj/
- [Root @ bogon myprj] # mkdir initial. commit
- [Root @ bogon initial. commit] # git init
- Initialized empty Git repository in/home/xfx-git/first/myprj/initial. commit/. git/
- [Root @ bogon initial. commit] # git remote add origin/home/xfx-git/first/myprj/
- [Root @ bogon initial. commit] # touch Readme
- [Root @ bogon initial. commit] # git add Readme
- [Root @ bogon initial. commit] # git commit-m "inner commit"
- [Master (root-commit) 5b6e14d] in‑commit
- Committer: root
- Your name and email address were configured automatically based
- On your username and hostname. Please check that they are accurate.
- You can suppress this message by setting them explicitly:
-
- Git config -- global user. name "Your Name"
- Git config -- global user. email you@example.com
-
- After doing this, you may fix the identity used for this commit:
-
- Git commit -- amend -- reset-author
-
- 0 files changed, 0 insertions (+), 0 deletions (-)
- Create mode 100644 Readme
- [Root @ bogon initial. commit] # git push origin master
- Counting objects: 3, done.
- Unpacking objects: 100% (3/3), done.
- Writing objects: 100% (3/3), 203 bytes, done.
- Total 3 (delta 0), reused 0 (delta 0)
- To/home/xfx-git/first/myprj/
- * [New branch] master-> master
4. The repository is activated and can be used normally.
- [Root @ bogon myclient] $ git clone/home/xfx-git/first/myprj
- Cloning into 'myprj '...
- Done.
- [Root @ bogon myclient] $ cd myprj
- [Root @ bogon myprj] $ vim Readme
- [Root @ bogon myprj] $ git commit-m "modify readme" Readme
- [Master 1bf69b4] modify readme
- 1 files changed, 1 insertions (+), 0 deletions (-)
- [Root @ bogon myprj] $ git push
- Counting objects: 5, done.
- Writing objects: 100% (3/3), 247 bytes, done.
- Total 3 (delta 0), reused 0 (delta 0)
- Unpacking objects: 100% (3/3), done.
- To/home/xfx-git/first/myprj
- 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