IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

十九、Git 远程服务搭建

IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

文章永久连接:https://tech.souyunku.com/?p=5245

我们可能需要与别人共享代码,协作开发

这时候我们就需要一台 Git 服务器作为远程 Git 仓库

下面我们就以在 Centos7 上安装 Git 服务器为例学习如何配置远程 Git 仓库

1. 安装 Git 依赖

[root@localhost ~]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel

2. 安装 Git

[root@localhost ~]# yum install git

3. 创建 git 用户和用户组

创建一个git用户组和用户,用来运行 Git 服务

[root@localhost ~]# groupadd git
[root@localhost ~]# adduser git -g git

4. 创建 ssh 登录证书

收集所有需要登录的用户的公钥,公钥位于 ~/.ssh/id_rsa.pub 文件中

把每个开发者的公钥导入到 /home/git/.ssh/authorized_keys 文件里,一行一个

如果没有 /home/git/.ssh/authorized_keys 文件则使用下面的命令创建

[root@localhost ~]# cd /home/git/
[root@localhost git]# mkdir .ssh
[root@localhost git]# chmod 700 .ssh
[root@localhost git]# touch .ssh/authorized_keys
[root@localhost git]# chmod 600 .ssh/authorized_keys

5、初始化 Git 仓库

首先我们选定一个目录作为 Git 仓库的根目录,一般情况下我们会在 git 用户目录下创建 repo 目录作为 Git 服务的根目录

首先切换到 git 用户

[root@localhost git]# su git
[git@localhost ~]$ mkdir /home/git/repo
[git@localhost ~]$ chown /home/git/repo git:git

然后在 repo 目录下创建我们的 Git 项目目录,比如 git-demo.git

目录名最好以 .git 结尾,这样在 git clone 或者 push 的时候 URL 路径更直观

[git@localhost ~]$ cd /home/home/git/repo
[git@localhost ~]$ mkdir git-demo.git
[git@localhost ~]$ chown git:git git-demo.git
[git@localhost ~]$ cd git-demo.git

[git@localhost ~]$ git init --bare .
Initialized empty Git repository in /home/git/repo/git-demo.git/

5. 禁用 git 用户登录

编辑 /etc/passwd 文件完成,找到有 git 那行

git:x:503:503::/home/git:/bin/bash

改为:

git:x:503:503::/home/git:/sbin/nologin

6. 克隆仓库

现在我们就可以克隆这个远程仓库了,假设我们服务器的 IP 是 192.168.1.8

$ git clone git@192.168.1.8:~/repo/git-demo.git
Cloning into 'git-demo'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.

如果出现类似的 Clone into 语句,则说明我们的 远程 Git 服务配置完成了

干货推荐

本站推荐:精选优质专栏

附录:Git:系列文章


Warning: A non-numeric value encountered in /data/wangzhan/tech.souyunku.com.wp/wp-content/themes/dux/functions-theme.php on line 1154
赞(96) 打赏



未经允许不得转载:搜云库技术团队 » 十九、Git 远程服务搭建

IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码
IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

评论 抢沙发

大前端WP主题 更专业 更方便

联系我们联系我们

觉得文章有用就打赏一下文章作者

微信扫一扫打赏

微信扫一扫打赏


Fatal error: Uncaught Exception: Cache directory not writable. Comet Cache needs this directory please: `/data/wangzhan/tech.souyunku.com.wp/wp-content/cache/comet-cache/cache/https/tech-souyunku-com/index.q`. Set permissions to `755` or higher; `777` might be needed in some cases. in /data/wangzhan/tech.souyunku.com.wp/wp-content/plugins/comet-cache/src/includes/traits/Ac/ObUtils.php:367 Stack trace: #0 [internal function]: WebSharks\CometCache\Classes\AdvancedCache->outputBufferCallbackHandler() #1 /data/wangzhan/tech.souyunku.com.wp/wp-includes/functions.php(5109): ob_end_flush() #2 /data/wangzhan/tech.souyunku.com.wp/wp-includes/class-wp-hook.php(303): wp_ob_end_flush_all() #3 /data/wangzhan/tech.souyunku.com.wp/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters() #4 /data/wangzhan/tech.souyunku.com.wp/wp-includes/plugin.php(470): WP_Hook->do_action() #5 /data/wangzhan/tech.souyunku.com.wp/wp-includes/load.php(1097): do_action() #6 [internal function]: shutdown_action_hook() #7 {main} thrown in /data/wangzhan/tech.souyunku.com.wp/wp-content/plugins/comet-cache/src/includes/traits/Ac/ObUtils.php on line 367