CentOS下Git的服务器版安装和使用

来源:互联网 发布:手机淘宝开店怎么激活 编辑:程序博客网 时间:2024/05/22 10:42

系统:#cat /etc/issue  --> CentOS release 6.5 (Final)和 #git --version --> git version 1.7.1


1:安装git:

  1. 安装git  
  2. yum install git  
  3. 版本git  
  4. git --version

2:搭建服务器:

  1. ①:创建git服务器工作空间:  
  2. #mkdir -p /home/repository/git  
  3. 注:-p参数:如果一个目录的父目录不存在,就创建它  
  4. ②:新建组和用户  
  5. #groupadd git  
  6. #useradd git -g git -d /home/repository/git/ -s /usr/bin/git-shell  
  7. 注:若不能执行则,先-s /bin/sh 后手动修改 /etc/passwd文件的/usr/bin/git-shell  
  8. #grep git /etc/passwd  
  9. git:x:501:501::/home/repository/git/:/usr/bin/git-shell  
  10. ③:更改权限git文件和目录权限:  
  11. #chown -R git.git /home/repository/git/  
  12. #ls -la  
  13. drwxr-xr-x  3 root root 4096 Jan 19 13:25 .  
  14. drwxr-xr-x. 6 root root 4096 Jan 17 22:51 ..  
  15. drwxr-xr-x  4 git  git  4096 Jan 19 13:25 git  
  16. ④:初始化Git服务器仓库:  
  17. 服务器上的Git仓库纯粹是为了共享,并且用户无权限直接登录到服务器上去改工作区,并且服务器上的Git仓库通常都以.git结尾。
  18. (可以先执行  cd /  把git版本库放根目录)
  19.  
  20. git init --bare lvshuotestgit.git  
  21. 注:a,不使用--bare选项时,就会生成.git目录以及其下的版本历史记录文件,这些版本历史记录文件就存放在.git目录下;  
  22. b,使用--bare选项时,不再生成.git目录,而是只生成.git目录下面的版本历史记录文件,这些版本历史记录文件也不再存放在.git目录下面,而是直接存放在版本库的根目录下面。  
  23. ⑤:本地用户生成自己的公钥,并收集所有用户的id_rsa.pub文件的信息,把所有公钥导入到/home/repository/git/.ssh/authorized_keys文件里:目录写错将出现错误2[文章末尾备注]文件里,一行一个!  
  24.   
  25. ⑥:本地clone代码,自己已经装好了git命令行[ip自己服务器]:  
  26. $ git clone root@116.196.82.203:22/lvshuotestgit.git  
  27. Cloning into 'lvshuotestgit'...  
  28. warning: You appear to have cloned an empty repository.  
  29. Checking connectivity... done.  
  30. 则ok! 

------------------------------------------------------------------------------------------------------------

centosGIT使


https://wenku.baidu.com/view/0128bdb8daef5ef7bb0d3c02.html



ssh://root@116.196.82.203:22/lvshuotestgit.git

原创粉丝点击