# 服务器 Git服务器搭建-实践篇 https://www.jianshu.com/p/d0da19c47a6d ## 安装 ### 源码编译 ```shell wget https://github.com/git/git/archive/refs/tags/v2.41.0.tar.gz --no-check-certificate tar -zvxf git-2.41.0.tar.gz cd git-2.41.0 make all prefix=/usr/local/git make install prefix=/usr/local/git echo 'export PATH=$PATH:/usr/local/git/bin' >> /etc/bashrc source /etc/bashrc git --version ``` ## 配置 ### 创建账号 ```shell useradd -m git passwd git ``` ### 创建仓库 ```shell mkdir -p /data/repositories cd /data/repositories/ && git init --bare zlib.git ``` ### 用户权限 ```shell chown -R git:git /data/repositories chmod 755 /data/repositories ``` ### 登录限制 ```shell git:x:500:500::/home/git:/usr/local/git/bin/git-shell ``` ## 使用 ```shell git clone git@175.24.226.114:/data/repositories/zlib.git ``` # 客户端 ```shell #设置 git config --global user.email ouczbs@qq.com git config --global user.name ouczbs git config --global push.default simple git remote set-url origin git@175.24.226.114:ouczbs/docker.git git remote -v git diff git log . git add . git commit m "push commit" git push ```