CentOS 6.4 搭建git 伺服器

來源:互聯網
上載者:User

標籤:tool   markdown   連接埠   yum   workspace   git push   error   get   操作   

CentOS 6.4 搭建git 伺服器 (2013-11-22 19:04:09)轉載▼標籤: it分類: Linux此檔案是依據markdown所編寫,更好效果參見本人github的文檔https://github.com/jackliu2013/recipes/blob/master/doc/linux/CentOS_6.4_git伺服器搭建.md##CentOS安裝Git伺服器 Centos 6.4 + Git 1.8.2.2 + gitosis##1.查看Linux系統伺服器系統版本```    cat /etc/redhat-release   # 查看系統版本        CentOS release 6.4 (Final)        ifconfig                 # 查看伺服器的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:16lo        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` - 同時下載git-1.8.2.2.tar.gz檔案,然後將其`mv` 到`/usr/local/src`目錄。[git-1.8.2.2.tar.gz安裝包][1]```cd /usr/local/srcsudo tar -zvxf git-1.8.2.2.tar.gzcd git-1.8.2.2sudo make prefix=/usr/local/git allsudo make prefix=/usr/local/git install``` - 增加軟串連```sudo ln -s /usr/local/git/bin/* /usr/bin/git --version  #如果能顯示版本號碼,即表示成功````3.在伺服器安裝gitosis```sudo yum install python python-setuptoolscd /usr/local/srcgit clone git://github.com/res0nat0r/gitosis.gitcd gitosispython setup.py install  #顯示Finished processing dependencies for gitosis==0.2即表示成功```4.在開發機上,生產密鑰並上傳到伺服器上```ssh-keygen -t rsa   #一路斷行符號,不需要設定密碼#上傳公開金鑰到伺服器(預設SSH連接埠22)scp ~/.ssh/id_rsa.pub [email protected]100.202:/tmp```或編輯`/etc/hosts`檔案,在`/etc/hosts`檔案裡添加如下文本:```# local git server192.168.100.202 zgit```然後再上傳自己的公開金鑰到伺服器```scp ~/.ssh/id_rsa.pub [email protected]:/tmp/# 登入到git伺服器ls /tmp/id_rsa.pub  #顯示已經上傳的密鑰```5.伺服器上產生git使用者,使用git使用者並初始化`gitosis````# 建立git版本系統管理使用者 gitsudo useradd -c ‘git version manage‘ -m -d /home/git -s bin/bash  git# 更改git使用者的密碼sudo passwd git# su 到git使用者su - gitgitosis-init < /tmp/id_rsa.pub#顯示以下資訊即表示成功#Initialized empty Git repository in /home/git/repositories/gitosis-admin.git/#Reinitialized existing Git repository in /home/git/repositories/gitosis-admin.git/#刪除密鑰rm -rf /tmp/id_rsa.pub```6.在個人開發機上匯出專案管理```mkdir -p /repocd /repogit clone [email protected]:gitosis-admin.git```7.在個人開發機增加及設定管理項目```cd /repo/gitosis-admin# 查看git伺服器已經上傳密鑰ls keydir  cat keydir/[email protected]  #[email protected]為已經上傳的開發機產生的公密#顯示密鑰 最後的字串為 密鑰使用者名稱 這裡為 [email protected]vim gitosis.conf#在檔案尾增加以下內容[group test-git]            # 具有寫入權限的組名稱writable = test-git         # 該組可寫的項目名稱members = [email protected]  [email protected]     #該組的成員(密鑰使用者名稱) 多個使用者協同開發時,以空格分隔# 如果要增加唯讀組 參考如下# [group test-git-readnoly]          # 具有都許可權的組名稱# readonly = test-git                # 該組唯讀項目名稱# members = [email protected]     # 該組的成員#提交修改git add .git commit -a -m "add test-git repo"git push```8.在個人開發機上初始,增加及使用項目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 [email protected]:test-git.git  git push origin master  ```9.增加協同開發人員的公開金鑰key到git伺服器    - 執行`cd repo/gitosis-admin/keydir`切換目錄  - 把協同開發人員的id_rsa.pub 檔案裡的資料 拷貝到 對應的開發人員的`密鑰使用者名稱.pub`檔案。如把密鑰使用者名稱 [email protected] 的 id_rsa.pub 檔案中文本 粘貼到 [email protected] 檔案裡,並儲存 - 然後將添加資料後的目錄更新到git伺服器  ```  git add .   git commit -am "add [email protected] file"   git push origin master    ```   本文檔參考: [CentOS git搭建參考1][2], [CentOs上搭建git伺服器][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/[email protected]:~/workspace/recipes/doc/linux$

  

CentOS 6.4 搭建git 伺服器

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.