git搭建

本文详细介绍了在虚拟机中搭建Git服务端的过程,包括安装Git、创建Git用户、初始化Git仓库及权限设置,同时提供了Windows客户端安装指导。

虚拟机安装的
[root@localhost ~]# yum -y install git
(之前搭建的是阿里云的yum源)

git版本:

[root@localhost ~]# git --version
git version 1.8.3.1

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

[root@localhost ~]# cd /home/
[root@localhost home]# ls
[root@localhost home]# id git
id: git: no such user (提示没有这个用户)
[root@localhost home]# useradd git
[root@localhost home]# passwd git
更改用户 git 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。

[root@localhost home]# mkdir -p ./git/repository/gittest.git
[root@localhost home]# ls
git
[root@localhost home]# cd git
[root@localhost git]# ls
repository
[root@localhost git]# cd repository/
[root@localhost repository]# ls
gittest.git

这步很重要,初始化项目测试目录

[root@localhost repository]# git init --bare ./gittest.git
初始化空的 Git 版本库于 /home/git/repository/gittest.git/

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

[root@localhost repository]# ll
总用量 0
drwxr-xr-x 7 root root 119 12月 11 19:04 gittest.git
#查看gittest.git项目文件夹的拥有者 #拥有者是root用户名
[root@localhost repository]# cd …
[root@localhost git]# ls
repository
[root@localhost git]# chown -R git:git repository #将拥有者改为git用户
[root@localhost git]# ll #再次查看gittest.git项目文件夹的拥有者
总用量 0
drwxr-xr-x 3 git git 25 12月 11 19:02 repository #拥有者是git用户

服务端就基本安装结束了,现在是要进行客户端的安装

windows 安装
下载地址: https://gitforwindows.org/

liunx系统下安装服务端具体的操作是可以参考 :https://www.linuxidc.com/Linux/2017-12/149803.htm

windows系统下安装客户端的具体操作是可以参考 :
https://blog.youkuaiyun.com/ytx2014214081/article/details/74556144

### 使用 Git 搭建网页版服务器 为了搭建一个基于 Git 的网页版服务器,可以采用多种工具和技术栈来实现这一目标。其中一种流行的选择是使用 Gitblit 来部署 Git 服务并提供 Web 界面访问功能。 #### 安装 Java 和 Git 确保 Windows 平台上已安装最新版本的 JDK (Java Development Kit),因为 Gitblit 是用 Java 编写的程序[^1]。同样也需要安装 Git 工具以便于后续操作中的命令行交互以及 SSH 密钥管理[^4]。 #### 下载与解压 Gitblit 前往官方 GitHub 页面下载适合 Windows 系统架构的 Gitblit 版本文件,并将其解压缩到指定位置。这一步骤完成后即可准备启动应用程序。 #### 配置 HTTPS 设置 对于安全连接的需求来说,可以通过修改 `gitblit.properties` 文件内的参数来进行 SSL/TLS 加密传输的支持: ```properties server.httpsBindInterface=localhost server.httpsPort=8443 server.keyStorePath=/path/to/keystore.jks server.keyStorePassword=myKeystorePassw0rd! ``` 上述配置指定了 HTTPS 绑定接口为本地主机地址 (`localhost`) 及端口号 (`8443`) ,同时定义了用于存储证书和私钥的 JKS(Java Key Store) 路径及其密码[^3]。 #### 启动 Gitblit 应用 通过双击运行位于解压包根目录下的 `run.bat` 批处理脚本来开启 Gitblit 服务进程。首次打开浏览器输入 http://localhost:8080 或者 https://localhost:8443 即可看到初始登录页面。 #### 用户名邮箱设置及SSH密钥生成 在成功建立好环境之后,建议先完成个人账户基本信息设定工作——即利用 git bash 命令行工具依次执行如下指令以注册全局身份信息;接着检查是否存在 `.ssh/id_rsa.pub` 公开秘钥文件夹,如果不存在则按照提示创建一对新的 RSA 类型 SSH 密钥对: ```bash $ git config --global user.name "Your Name" $ git config --global user.email you@example.com $ cd ~/.ssh/ $ ls -al # 如果没有 id_rsa 和 id_rsa.pub,则继续下一步 $ ssh-keygen -t rsa -C "you@example.com" ``` #### 创建仓库并与客户端同步 最后回到 Gitblit 控制台界面新建项目库,并允许外部贡献者推送更改记录至远程分支上。与此同时,开发者们可以在各自的工作站里克隆一份副本下来开展协作开发活动。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

运维螺丝钉

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

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

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

打赏作者

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

抵扣说明:

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

余额充值