远程测试服务器创建git仓库,以便协作开发
1.远程服务器登录,新增用户 test 并为test设置密码
adduser test

输入两次密码,并确认用户

切换用户为 test 并切换到用户根目录
su test
cd

2.设置 ssh免密登录
确保ssh 已安装
ssh-keygen -t rsa 一直 Enter

用户根目录下 回有 .ssh 文件夹 创建 authorized_keys
cd .ssh
touch authorized_keys
vim authorized_keys
从本地 拿到 要免密登录的机器用户的 id_rsa.pub 中的密钥,依次存入authorized_keys中

本地免密登录测试
ssh test@1806.cksoft.win

3.创建远程 git 仓库
若远程服务器未安装git 安装设置过忽略下面两步
apt-get install git
设置git
git config --global --globsl user.name 'your name'
git config --global --globsl user.email 'your email'
开始创建仓库
mkdir project.git
cd project.git
git --bare inti

4.本地新建仓库加入远程仓库
mkdir myproject
cd myproject
git init
新增文件
touch test.txt
git add .
git commit -m 'frist commit'
git remote add origin test@1806.cksoft.win:/home/test/project.git
git push origin master

5. 远程仓库中git log 查看提交
git log

提交成功
远程仓库要查看提交文件 需 git checkout
可在本地 测试查看提交内容
git clone test@1806.cksot.win:/home/test/project.git

网友评论