龙空技术网

Linux Centos7下搭建简单的git服务器

MacLex 508

前言:

当前同学们对“centos7git安装详解”都比较讲究,各位老铁们都需要知道一些“centos7git安装详解”的相关文章。那么小编在网上汇集了一些关于“centos7git安装详解””的相关资讯,希望我们能喜欢,大家快快来了解一下吧!

下载git并初始化

10.211.55.3 作为服务端git server

yum install -y git 

这个主机安装git命令

# useradd git# passwd git# su gitcentos7 git@parallels:~$ pwd/home/gitcentos7 git@parallels:~$ mkdir -p repos/app.git && cd ./repos/app.git

总库初始化、总库一般都是空库

centos7 git@parallels:~/repos/app.git$ git --bare initInitialized empty Git repository in /home/git/repos/app.git/

然后用我的macOS作为客户端:

首先实现免密钥到服务器:

ssh公钥实现免交互,将我Mac的key放到git服务器10.211.55.3上在10.211.55.3上操作如下:centos7 git@parallels:~/repos$ mkdir /home/git/.ssh && chmod 700 /home/git/.sshcentos7 git@parallels:~/repos$ cd /home/git/.ssh/centos7 git@parallels:~/.ssh$ vi authorized_keyscentos7 git@parallels:~/.ssh$ chmod 600 authorized_keys

放到对应的authorized_keys里面去

第三部从客户端开始测试,当然客户端也是有git命令的

测试能否正常使用git,本地先创建文件准备提交git服务器

➜  git pwd/Users/lex/Downloads/git➜  git mkdir test-git➜  test-git git clone git@10.211.55.3:/home/git/repos/app.git➜  test-git git clone git@10.211.55.3:/home/git/repos/app.gitCloning into 'app'...  ___                 ___ (o o)               (o o)(  V  ) ALex CentOS (  V  )--m-m-----------------m-m--remote: Counting objects: 3, done.remote: Total 3 (delta 0), reused 0 (delta 0)Receiving objects: 100% (3/3), done.➜  test-git cd app➜  app git:(master) lsindex.html➜  app git:(master) tree.└── index.html0 directories, 1 file➜  app git:(master) touch index2.html && echo 456 > index2.html➜  app git:(master) ✗ git statusOn branch masterYour branch is up to date with 'origin/master'.Untracked files:  (use "git add <file>..." to include in what will be committed)	index2.htmlnothing added to commit but untracked files present (use "git add" to track)➜  app git:(master) ✗ git add index2.html强行插入2行,第一次commit代码的时候下面是需要设置的,否责推送会报错error: src refspec refs/heads/master does not match any详细参考文章结尾部分:➜  app git:(master) ✗ git config --global user.email "abc@outlook.com"➜  app git:(master) ✗ git config --global user.name "ALex"➜  app git:(master) ✗ git commit -m "secend commit"[master b726e76] secend commit 1 file changed, 1 insertion(+) create mode 100644 index2.html➜  app git:(master) git push  ___                 ___ (o o)               (o o)(  V  ) ALex CentOS (  V  )--m-m-----------------m-m--Enumerating objects: 4, done.Counting objects: 100% (4/4), done.Delta compression using up to 12 threadsCompressing objects: 100% (2/2), done.Writing objects: 100% (3/3), 270 bytes | 270.00 KiB/s, done.Total 3 (delta 0), reused 0 (delta 0), pack-reused 0To 10.211.55.3:/home/git/repos/app.git   36fc8b8..b726e76  master -> master

*** Please tell me who you are.

Run

git config --global user.email "you@example.com"

git config --global user.name "Your Name"

to set your account's default identity.

Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'lex@Mac.(none)')

上面这个错误是致命的,所以首先要执行上面这个命令

否责下面都过不去

标签: #centos7git安装详解