简单搭建Git Server

  • Post author:
  • Post category:其他


server side

安装 git-core, openssh-server, openssh-client

sudo apt-get install git-core

sudo apt-get install openssh-server

sudo apt-get install openssh-client

添加一个git用户

sudo adduser git

切换到git用户

su git

创建.ssh目录和authorized_keys文件

cd

mkdir .ssh

cd .ssh

touch authorized_keys

chmod 700 /home/git/.ssh/

chmod 600 /home/git/.ssh/authorized_keys

初始化一个不包含工作目录的仓库

cd

mkdir pro.git

cd pro.git

git –bare init

client side

产生ssh key

ssh-keygen -t rsa

拷贝~/.ssh/id_rsa.pub到server side

server side

拷贝id_rsa.pub内容到authorized_keys

cat id_rsa.pub >> ~/.ssh/authorized_keys

client side

测试ssh连接

ssh git@serverip

建立本例仓库

mkdir pro_git

cd pro_git

git init

本地仓库推送到Server side

git config –global user.email “wangyang@irisking.com”

git config –global user.name “wangyang”

touch test.txt

git add test.txt

git commit -m ‘first’

git remote add origin git@serverip:/home/git/pro.git

git push origin master

git clone

git clone git@10.2.10.240:/home/git/6.0_git



版权声明:本文为fisher_2005原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。