Git 环境配置
- One minute read - 100 wordsGit版本管理工具配置
1 本地自建git服务
1.1 环境准备
- 两台ubuntu虚拟机 + git
- 安装git
apt-get update apt-get install git -y
1.2 环境搭建
1.2.1 server端搭建
- 创建git用户
useradd git -d /home/git -m -s /bin/bash
- 设置账号密码
passwd git # 输入自定义用户密码,此处测试使用 123456
- 切换git用户创建git托管服务
# 切换到git家目录 su git cd ~ # 初始化git仓库 git init --bare sample.git # 查看仓库目录 ls -R .: sample.git ./sample.git: HEAD branches config description hooks info objects refs
1.2.2 client端搭建
- 上传ssh密钥
ssh-copy-id -i ~/.ssh/id_rsa.pub git@${serverIP} # 输入1.2.1中步骤2设置的git用户密码
- clone远程仓库
git clone git@${serverIP}:/home/git/sample.git cd sample
- 配置git邮箱/用户名
git config --global user.email "${邮箱}" git config --global user.name "${用户名}"
- 改动文件,提交远程仓库
touch readme.md git add . git commit -m "feat: init" git push