ubuntu下面的git服务器搭建
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                ubuntu下面的git服务器搭建
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                1、安裝相應的軟件和依賴
 
2、配置服務器
在服務器端
 
查看ssh有沒有啟動
root@weiqifa-Inspiron-3847:/home/git# ps -e|grep ssh1686 ? 00:00:00 sshd root@weiqifa-Inspiron-3847:/home/git#創建git用戶,用來管理代碼的用戶 root@weiqifa-Inspiron-3847:/home/git# sudo useradd git useradd: user 'git' already exists root@weiqifa-Inspiron-3847:/home/git#
秘鑰文件
在gitServer上我們首先查看/home/git/.ssh目錄下是否存在authorized_kesys文件,
如果沒有,可以通過touch authorized_keys創建此文件。
在客戶機端
在客戶端用ssh-keygen -t rsa 生成秘鑰
然后用命令scp把秘鑰復制到服務器
scp id_rsa.pub weiqifa@192.168.0.88:/home/git/.ssh/然后回到服務器 root@weiqifa-Inspiron-3847:/home/git/.ssh# ls authorized_keys id_rsa.pub root@weiqifa-Inspiron-3847:/home/git/.ssh# cat id_rsa.pub >> authorized_keys root@weiqifa-Inspiron-3847:/home/git/.ssh# cat authorized_keys ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDkIt2Hh532FoWoj0IUztIYF+jz4F1KvyOAmrhpxUMnnuj+YEOhyw6AGL/NAjmE5r8SzeJLTtAkVk9s143R9tYouPOgHPuwTTFvDy/skjD14yMne1aHzre2rM0jGiv5gtZDmi523FvQob7oTM5xOKKk3lsMBQNPdWrPPWqs8kS941sdWYymNQqFLBH4DpzDUAS+Itk5U6aNvVcQbldmGR+F3IxIKxH76HwpTmh+Os5fqraQLOMpWZzu8h0KMMMnNdideV0lHfq40Swb0ZO6ZGy/tdXBTc7oO8bn11oRVQ+Uf+USYMBzB6PCe6gODI3Fp0cBFzzQNque6MIAh6ELClUn Administrator@JU674J315CAOGPV root@weiqifa-Inspiron-3847:/home/git/.ssh#
 
3、建立倉庫并克隆
 建立個文件夾用來管理倉庫
在服務器測試clone一下
root@weiqifa-Inspiron-3847:/home/git# cd repo/ root@weiqifa-Inspiron-3847:/home/git/repo# git init --bare sscom.git Initialized empty Git repository in /home/git/repo/sscom.git/ root@weiqifa-Inspiron-3847:/home/git/repo# cd ../ root@weiqifa-Inspiron-3847:/home/git# ls bin examples.desktop gitosis id_rsa.pub repo root@weiqifa-Inspiron-3847:/home/git# cd ../ root@weiqifa-Inspiron-3847:/home# git clone --bare git git/ gitrepository/ root@weiqifa-Inspiron-3847:/home# git clone --bare git/repo/sscom.git/ Cloning into bare repository 'sscom.git'... warning: You appear to have cloned an empty repository. done. root@weiqifa-Inspiron-3847:/home# ls git gitrepository lost+found sscom.git weiqifa root@weiqifa-Inspiron-3847:/home#
在客戶端clone一下 Administrator@JU674J315CAOGPV MINGW64 ~/.ssh $ git clone git@192.168.0.88:/home/git/repo/sscom.git Cloning into 'sscom'... git@192.168.0.88's password: warning: You appear to have cloned an empty repository. Checking connectivity... done.
在客戶端push 一下 Administrator@JU674J315CAOGPV MINGW64 ~/.ssh $ git clone git@192.168.0.88:/home/git/repo/sscom.git Cloning into 'sscom'... git@192.168.0.88's password: warning: You appear to have cloned an empty repository. Checking connectivity... done.Administrator@JU674J315CAOGPV MINGW64 ~/.ssh $ ls id_rsa id_rsa.pub known_hosts sample/ sscom/Administrator@JU674J315CAOGPV MINGW64 ~/.ssh $ cd sscom/Administrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master) $ ^CAdministrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master) $ lsAdministrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master) $ pwd /c/Users/Administrator/.ssh/sscomAdministrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master) $ git branchAdministrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master) $ echo "this beginnings of project1" > any.fileAdministrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master) $ git add . warning: LF will be replaced by CRLF in any.file. The file will have its original line endings in your working directory.Administrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master) $ git commit -m "init" [master (root-commit) e9565b2] init warning: LF will be replaced by CRLF in any.file. The file will have its original line endings in your working directory.1 file changed, 1 insertion(+)create mode 100644 any.fileAdministrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master) $ git push origin master git@192.168.0.88's password: Counting objects: 3, done. Writing objects: 100% (3/3), 229 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) remote: error: insufficient permission for adding an object to repository database ./objects remote: fatal: failed to write object error: unpack failed: unpack-objects abnormal exit To git@192.168.0.88:/home/git/repo/sscom.git! [remote rejected] master -> master (unpacker error) error: failed to push some refs to 'git@192.168.0.88:/home/git/repo/sscom.git'
這個錯誤查看了一下這個鏈接
http://blog.csdn.net/yujunf/article/details/7595231
在服務器然后再修改一下
root@weiqifa-Inspiron-3847:/home/git/repo# ls sscom.git root@weiqifa-Inspiron-3847:/home/git/repo# chown -R git:git sscom.git/ root@weiqifa-Inspiron-3847:/home/git/repo#回到客戶端再push一下 Administrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master) $ git push git@192.168.0.88's password: Counting objects: 3, done. Writing objects: 100% (3/3), 229 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To git@192.168.0.88:/home/git/repo/sscom.git* [new branch] master -> masterAdministrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master)
4、總結
1、原理問題查清楚,哪步在哪里執行,要搞清楚
2、認真仔細,ubuntu對用戶權限要求比較高,要特別注意一下
3、學會在網查資料
 
 
參考資料:
http://www.linuxdiyf.com/linux/12685.html
https://hacpai.com/article/1445337139234
http://www.linuxdiyf.com/linux/12159.html
http://www.linuxdiyf.com/linux/10730.html
http://www.gitguys.com/topics/creating-a-shared-repository-users-sharing-the-repository/
 
總結
以上是生活随笔為你收集整理的ubuntu下面的git服务器搭建的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: QT 快捷键 识别小写字母
- 下一篇: Linux cpu亲和力
