一、
搭建仓库:git init
设置upstream
git remote -v
git remote rm orgin
git remote add origin git@github.com:*/*.git
git push--set-upstream origin master
二、
搭建服务器:git init --bare
查看是否有git用户
id git
创建git用户
adduser git
设置密码
passwd git
登录git用户
su git
cd ~
创建ssh
mkdir .ssh && chmod 700 .ssh
touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys
在另一台机上 ssh-keygen -t RSA -C "IP"生成id_rsa 与id_rsa.pub并将id_rsa.pub的内容复制到本机的.ssh/authorized_keys上
在另一台上ssh git@"本机IP"尝试能否免密连接
创建git server
cd ~
git init --bare simple.git
在另一台机上git clone simple.git
git clone git@IP:/home/git/simple.git
可能出现的报错:
bash: git-upload-pack: command not found
fatal: Could not read from remote repository.
查看两台机器的git目录(whereis git),若为usr/local/git则执行以下操作
ln -s /usr/local/git/bin/git-upload-pack /usr/bin/git-upload-pack
ln -s /usr/local/git/bin/git-receive-pack /usr/bin/git-receive-pack
设置禁止bash登录git用户
vim /etc/passwd
修改git:x:1001:1002::/home/git:/bin/git-bash为git:x:1001:1002::/home/git:/bin/git-shell