CentOS 6.4 build git server

This file is written based on markdown. For better results, please refer to my github document https://github.com/jackliu2013/recipes/blob/master/doc/linux/CentOS_6.4_git server building.md


##CentOS install Git server Centos 6.4 + Git 1.8.2.2 + gitosis##

1. Check Linux system server system

version```
    cat /etc/redhat-release # Check system version
    
    CentOS release 6.4 (Final)
    
    ifconfig # Check server IP
    eth0      
          Link encap:Ethernet HWaddr 00:23:8B:FA:78:92  
          inet addr:192.168.100.202 Bcast:192.168.100.255 Mask:255.255.255.0
          inet6 addr: fe80::223:8bff:fefa:7892/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST MTU :1500 Metric:1
          RX packets:543645 errors:0 dropped:0 overruns:0 frame:0
          TX packets:157155 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:383527379 (365.7 MiB)  TX bytes:13270106 (12.6 MiB)
          Interrupt:16

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

```

2.在服务器上安装git及做些操作

 - 执行命令
`
sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel
`
 - also download the git-1.8.2.2.tar.gz file, then `mv` it to `/usr/local/src `Directory. [git-1.8.2.2.tar.gz installation package download address][1]

```
cd /usr/local/src
sudo tar -zvxf git-1.8.2.2.tar.gz
cd git-1.8.2.2

sudo make prefix =/usr/local/git all
sudo make prefix=/usr/local/git install

```

 - add soft link
```
sudo ln -s /usr/local/git/bin/* /usr/bin/

git - -version #If the version number can be displayed, it means success `

`

3. Install gitosis
``` on the server
sudo yum install python python-setuptools

cd /usr/local/src

git clone git://github.com/res0nat0r /gitosis.git

cd gitosis

python setup.py install  

#Display Finished processing dependencies for gitosis==0.2 means success

```


4. On the development machine, produce the key and upload it to the server
```
ssh-keygen -t rsa #Enter all the way, no need to set a password

#Upload Public key to server (default SSH port 22)
scp ~/.ssh/id_rsa.pub [email protected]:/tmp
```

or edit `/etc/hosts` file, add in `/etc/hosts` file The following text:
```
# local git server
192.168.100.202 zgit
```
Then upload your own public key to the server
```
scp ~/.ssh/id_rsa.pub tailin@zgit:/tmp/

# Log in to the git server
ls /tmp/id_rsa.pub #Display the uploaded key``` 5. Generate a git user on the server, use the git user and initialize `gitosis` ``

` #Create a git version management user git sudo useradd -c 'git version manage' -m -d /home/git -s bin/bash git # Change the password of the git user sudo passwd git










# su to git user
su - git
gitosis-init < /tmp/id_rsa.pub #Display

the following information means success
#Initialized empty Git repository in /home/git/repositories/gitosis-admin.git/
#Reinitialized existing Git repository in /home/git/repositories/gitosis-admin.git/ #Delete the

key
rm -rf /tmp/id_rsa.pub

``` 6. Export project management ``` mkdir -p /repo cd /repo git

on the personal development machine clone git@zgit:gitosis-admin.git ``` 7. Add and set management items on the personal development machine ``` cd /repo/gitosis-admin # Check that the git server has uploaded the key ls keydir   cat keydir/ltl@jackliu -ThinkPad.pub   #[email protected] is the public secret generated by the uploaded development machine #display the key The last string is the key user name here is ltl@jackliu-ThinkPad vim gitosis.conf





















#Add the following content at the end of the file

[group test-git] # The group name with write permission
writable = test-git # The project name that the group can write
members = ltl@jackliu-ThinkPad [email protected] #The group member (key user name) When multiple users develop collaboratively, they are separated by spaces

# If you want to add a read-only group, please refer to the following
# [group test-git-readnoly] # The name of the group with all permissions
# readonly = test-git # The read-only project name of the group
# members = ltl@jackliu-ThinkPad # Members of the group


# Commit changes
git add .
git commit -a -m "add test-git repo"
git push

```

8. In personal development Initial on the machine, adding and using the project test-git

````
cd ~/repo  

mkdir test-git   

cd test-git  

git init  

touch readme  

git add .   

git commit -a -m "init test-git"  

git remote add origin git@zgit:test-git.git  

git push origin master  

```

9. Add the public key of the co-developer to the git server  
 
 - execute `cd repo/gitosis-admin/keydir` to switch the directory
 
 - put the co- developer The data in the developer's id_rsa.pub file is copied to the corresponding developer's `key username.pub` file. For example, paste the text in the id_rsa.pub file of the key username [email protected] into the [email protected] file and save it  -

 then update the directory after adding the data to the git server``
 
`
 
 git add .  
 git commit -am "add [email protected] file"  
 git push origin master  
 
 ```
 

 
 This document reference:
 [CentOS git construction reference 1][2],
 [CentOs builds git server] [3]

  [1]: http://code.google.com/p/git-core
  [2]: http://blog.sina.com.cn/s/blog_86fe5b440101975o.html
  [3]: http://www.cnblogs.com/nasa/archive/2012/05/31/2528901.htmljackliu@jackliu-ThinkPad:~/workspace/recipes/doc/linux$

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327076817&siteId=291194637