Centos7 搭建自己的 git 服务器并创建 git 仓库

本文档详细介绍了如何在Centos7上搭建Git服务器并创建仓库,包括安装Git、创建git用户、初始化仓库、配置权限,以及客户端的连接与提交代码的步骤。此外,还提供了在使用过程中遇到的错误及其解决方案,如拒绝更新分支和查看push后内容的方法。
摘要由CSDN通过智能技术生成

Centos7 搭建自己的 git 服务器并创建 git 仓库
网上有很多这样的文章,今天要搭一个自己的git仓库,就记录了一下过程,供以后参考一些内容来源于网络
1、查看服务器上是否安装了git
[root@localhost ~]# rpm -aq |grep git
如果安装了可以用 rpm -e --nodeps 强制删除
2、本次安装使用yum 安装
1.[root@localhost ~]# yum install -y git
2.[root@localhost ~]# yum install -y git-daemon
3.查看一下是否安装成功
[root@localhost ~]# git --version
git version 1.8.3.1
3、 服务器端创建 git 用户,用来管理 Git 服务,并为 git 用户设置密码
[root@localhost ~]# id git
id: git: no such user
[root@localhost ~]# useradd git
[root@localhost ~]# passwd git
Changing password for user git.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]# id git
uid=1002(git) gid=1002(git) groups=1002(git)
[root@localhost ~]#
4、在服务器端创建 Git 仓库并初始化
1.设置 /home/git/data/repo 为git仓库
[root@localhost ~]# mkdir -p /home/git/data/repo
[root@localhost repo]# cd /home/git/data/repo
[root@localhost repo]# git --bare init
2.然后把 Git 仓库的 owner 修改为 git
[root@localhost ~]# chown -R git:git /home/git/data
3.修改仓库的 mod 权限
chmod -R 775 /home/git/data
5、本地机客户端
Administrator@SC-202101271001 MINGW64 /d
$ mkdir repo
Administrator@SC-202101271001 MINGW64 /d (master)
$ cd repo
Administrator@SC-202101271001 MINGW64 /d/repo (master)
$ git init
Initialized empty Git repository in D:/repo/.git/
配置账号邮箱
git config --global user.name “Administrator”
git config --global user.email “admin@example.com”
连接远程仓库
git remote add origin ssh://192.168.110.98/home/git/data/repo.git/repo
在这里插入图片描述
##################################################################
下面就可以推送你的信息了

一 首次提交代码到git仓

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

老男人---一位自学路上的菜鸟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值