git windows 查看linux,Linux上搭建Git服务,客户端在Windows

环境

服务器 CentOS Linux release 7.4.1708 (Core) + git(version 1.8.3.1)

客户端 Windows7 + git(Git-2.9.3.2-64-bit.exe)

① 安装 Git

Linux 做为Git服务器端系统,Windows 作为客户端系统,分别安装 Git

服务器端:

#yum install -y git

安装完后,查看 Git 版本

[root@localhost ~]# git --version

git version 1.8.3.1

客户端:

安装完之后,可以使用 Git Bash 作为命令行客户端。

安装完之后,查看 Git 版本

$ git --version

git version 2.9.3.windows.2

② 服务器端创建 git 用户,用来管理 Git 服务,并为 git 用户设置密码

[root@localhost home]# id git

id: git:无此用户

[root@localhost home]# useradd git

[root@localhost home]# passwd git

③ 服务器端创建 Git 仓库

设置 /home/data/git/gittest.git 为 Git 仓库

然后把 Git 仓库的 owner 修改为 git

[root@localhost home]# mkdir -p data/git/gittest.git

[root@localhost home]# git init --bare data/git/gittest.git

Initialized empty Git repository in /home/data/git/gittest.git/ [root@localhost home]# cd data/git/ [root@localhost git]# chown -R git:git gittest.git/

④ 客户端 clone 远程仓库

进入 Git Bash 命令行客户端,创建项目地址(设置在 d:/www/githome)并进入:

Administrator@PC MINGW64 /d/www/githome

$ cd /d/www/githome

Administrator@PC MINGW64 /d/www/githome

然后从 Linux Git 服务器上 clone 项目:

$ git clone git@192.168.56.101:/home/data/gittest.git

如果SSH用的不是默认的22端口,则需要使用以下的命令(假设SSH端口号是7700):

$ git clone ssh://git@192.168.0.111:7700/home/data/gittest.git

增加新的用户

[root@localhost home]# id git01

id: git01:无此用户

[root@localhost home]# useradd git01

[root@localhost home]# passwd git01

禁用git01用户的shell登陆

出于安全考虑,第二步创建的git01用户不允许登录shell,这可以通过编辑/etc/passwd文件完成。找到类似下面的一行:

git01:x:1001:1001:,,,:/home/git01:/bin/bash

1最后一个冒号后改为:

git01:x:1001:1001:,,,:/home/git01:/usr/bin/git-shell

这样,git01用户可以正常通过ssh使用git,但无法登录shell,因为我们为git01用户指定的git-shell每次一登录就自动退出。

问题1

问题描述:fatal: destination path 'githome' already exists and is not an empty directory.

解决方法:换了一个空的目录,重新

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值