rhces 发表于 2017-6-1 12:17:28

centos 搭建git服务器

centos 6搭建git服务器


[*]安装



rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-6.noarch.rpm
yum install -y git

[*]创建git用户



useradd git
passwd git


[*]初始化git仓库



cd /home
mkdir git
cd git
mkdir learngit.git
git init --bare learngit.git
chown -R git:git learngit.git




[*]禁用shell登录



vi /etc/passwd

  git:x:502:502::/home/git:/bin/bash
  改成
  git:x:502:502::/home/git:/usr/bin/git-shell


[*]本地测试(windows 7)



cd localtest
git init
git remote add origin ssh://git@10.10.83.162:45685/home/git/learngit.git

  上面的命令在本地创建了一个文件夹并添加了服务器上的远程仓库



touch a.txt
git add a.txt
git commit -m "init commit"

  上面的命令在本地创建了一个a.txt并在本地提交了一次



git push origin master

  将本地代码push到远程服务器上去


[*]本地clone



mkdir ttt
cd ttt
git clone ssh://git@10.10.83.162:45685/home/git/learngit.git

  之前push到服务器上的a.txt文件已经被clone下来

git 常用命令
  git init 初始化本地仓库
  git remote add origin http://10.10.83.171:10080/wangjian/etm-py.git 创建远程仓库
  git add . 添加
  git commit -m "ok" 提交
  git rm index.ph 删除
  git push origin master 上传
  git pull origin master 下载
  git clone http://10.10.83.171:10080/wangjian/etm-py.git 克隆
  
常用 Git 命令清单 http://www.ruanyifeng.com/blog/2015/12/git-cheat-sheet.html
页: [1]
查看完整版本: centos 搭建git服务器