k668 发表于 2018-9-18 07:25:09

git 服务器安装

  说明:记录一下
useradd git  
yum install git-core
  
su git
  
mkdir /home/git/repositories
  
git init --bare myprj
  在任意一个客户端执行
  如果没有安装git,可以先执行 yum install git
  设置客户端的用户名和email
git config --global user.name name1  
git config --global user.email name1@example.com
  初始化
mkdir initial.commit  
cd initial.commit/
  
git init
  
git remote add origingit@node2:/home/git/repositories/myprj/
  
touch Readme
  
git add .
  
git commit -m "add Readme"
  安装完成
  客户端使用方法:
  先配置ssh免密码登陆
  设置用户名和email
git config --global user.name name1  
git config --global user.email name1@example.com
  然后在客户端执行
  同步版本库
git clonegit@node2:/home/git/repositories/myprj/  提交本地文件到服务器上
touch test1  
git add test1
  
git commit -m "add test1"
  
git push
  下载服务器上的版本库到本地
git pull  配置ssh免登陆方法
  在客户端执行
  ssh-keygen 然后一直回车
  在服务器端执行
mkdir -p /home/git/.ssh/  
touch/home/git/.ssh/authorized_keys
  拷贝客户端的公钥到服务器端的authorized_keys中
  客户端公钥位置: /home/name1/.ssh/id_rsa.pub name1为客户端用户名,将id_rsa.pub中的内容写入到authorized_keys中
chmod 600 authorized_keys  完成,测试方法 ssh git@node2 直接可以登陆
  参考链接:http://aoingl.iteye.com/blog/1365201


页: [1]
查看完整版本: git 服务器安装