进入/home/soft目录,直接下载安装git,先不用安装一大推的扩展,等安装过程中报错了,看需要哪个扩展再装哪个~
cd /home/soft/ wget https://github.com/git/git/archive/v2.16.2.tar.gz tar -zxvf v2.16.2.tar.gz cd git-2.16.2 mkdir /usr/local/git make prefix=/usr/local/git #报错了,libiconv错误
下载安装libiconv ```bash cd /home/soft wget http://FTP.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz tar -zxvf libiconv-1.14.tar.gz cd libiconv-1.14 ./configure --prefix=/usr/local/libiconv && make && make install 编译libiconv发生./stdio.h:1010:1: 错误:'gets'未声明(不在函数内) 解决如下: ```bash cd srclib/ #进到出错文件的目录 sed -i -e '/gets is a security/d' ./stdio.in.h #编辑出错文件 cd ../ #回到编译对象目录 make #重新Make安装 ``` 至此libiconv安装结束
cd /home/soft/git-2.16.2 make clean #清理之前的编译文件 make prefix=/usr/local/git #重新执行安装,但是依旧报错,libiconv错误
make clean make configure ./configure --prefix=/usr/local --with-iconv=/usr/local/libiconv/ make install
安装成功!
ln -s /usr/local/git/bin/git /usr/bin/git
git --version
创建git用户,导入公钥。
创建用户与组
groupadd git useradd git cd /home/git/ mkdir .ssh #新建文件夹 chmod 700 .ssh touch .ssh/authorized_keys #新建文件 chmod 600 .ssh/authorized_keys
ssh-keygen -t rsa -C "893371810@QQ.com" cd /home/lypeng/.ssh/
拷贝到服务器
scp id_rsa.pub lypeng@your_ip:/home/lypeng/id_rsa.pub
登录服务器,将公钥导入到auth验证文件
vim /home/git/.ssh/authorized_keys :r /home/lypeng/id_rsa.pub :wq
开启ssh中的RSA认证
vim /etc/ssh/sshd_config RSAAuthentication yes PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys
创建仓库
cd /home/git git init —bare test.git
本地克隆仓库,提交测试
mkdir /home/gitrepo cd /home/gitrepo git clone git@your-ip:test.git echo 123456 > a.txt git add a.txt git commit -m ‘first’ git remote add mytestrepo git@your_ip:test.git git push -u mytestrepo master
发生错误如下:
git@your_ip’s password: 对象计数中: 3, 完成. 写入对象中: 100% (3/3), 200 bytes | 0 bytes/s, 完成. Total 3 (delta 0), reused 0 (delta 0) error: unpack failed: unable to create temporary object directory To git@your_ip:test.git ! [remote rejected] master -> master (unpacker error) error: 无法推送一些引用到 ‘git@your_ip:test.git’
unable to create temporary object directory
,无法创建临时目录,看样子应该是权限问题,怀疑是.git文件夹写权限问题。
给个test.git整体777试试
chmod 777 test.git -R git push mytestrepo
ok,提交成功!
至此,clone push等测试结束!