当前位置:
首页 >
搭建私有Git服务器
发布时间:2025/3/21
41
豆豆
生活随笔
收集整理的这篇文章主要介绍了
搭建私有Git服务器
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
前言
远程仓库实际上和本地仓库没啥不同,纯粹为了7x24小时开机并交换大家的修改。GitHub就是一个免费托管开源代码的远程仓库。但是对于某些视源代码如生命的商业公司来说,既不想公开源代码,又舍不得给GitHub交保护费,那就只能自己搭建一台Git服务器作为私有仓库使用。
搭建Git服务器需要准备一台运行Linux的机器,在此我们使用CentOS7.6。以下为安装步骤:
操作步骤:
步骤: 1、安装git服务环境准备 yum -y install curl curl-devel zlib-devel openssl-devel perl cpio expat-devel gettext-devel gcc cc 2、下载git-2.5.0.tar.gz 1)解压缩 2)cd git-2.5.0 3)autoconf 4)./configure 5)make 6)make install 3、添加用户 adduser -r -c 'git version control' -d /home/git -m git 此命令执行后会创建/home/git目录作为git用户的主目录。 5、设置密码 passwd git 输入两次密码 6、切换到git用户 su git 7、创建git仓库 git --bare init /home/git/first 注意:如果不使用“--bare”参数,初始化仓库后,提交master分支时报错。这是由于git默认拒绝了push操作,需要.git/config添加如下代码: [receive]denyCurrentBranch = ignore 推荐使用:git --bare init初始化仓库。8、连接服务器 私有git服务器搭建完成后就可以向连接github一样连接使用了,但是我们的git服务器并没有配置密钥登录,所以每次连接时需要输入密码。 使用命令连接(Git Bash): $ git remote add origin ssh://git@192.168.25.156/home/git/first 或 $ git remote add origin git@192.168.25.156:first安装中可能出现的问题:
1、需要安装autoconf
yum install autoconf
2、报错:
/usr/bin/perl Makefile.PL PREFIX='/usr/local' INSTALL_BASE='' --localedir='/usr/local/share/locale' Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/sare/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 3. BEGIN failed--compilation aborted at Makefile.PL line 3. make[1]: *** [perl.mak] Error 2 make: *** [perl/perl.mak] Error 2解决:
yum install perl-ExtUtils-MakeMaker package
使用乌龟同步代码:
使用idea同步代码:
使用idea同步代码跟在GitHub的操作一样(只是改了路径)
https://blog.csdn.net/weixin_41699562/article/details/95675537
总结
以上是生活随笔为你收集整理的搭建私有Git服务器的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: centos7.6基础
- 下一篇: Typora最好用的Markdown编辑