内网Windows系统离线安装Git详细步骤
下载离线安装包
-
在有互联网连接的计算机上访问Git官网下载页面:
https://git-scm.com/download/win
-
下载"Standalone Installer"版本的Git安装程序(如Git-2.xx.x-64-bit.exe)
-
将下载的安装文件拷贝到内网Windows系统中
安装Git
- 双击运行Git安装程序
- 选择安装位置(默认即可)
- 选择组件(建议全选):
- Git Bash
- Git GUI
- Git LFS
- 关联.git文件等
- 选择开始菜单文件夹(默认即可)
- 选择默认编辑器(推荐选择Vim或VS Code如果已安装)
- 调整PATH环境:
- 选择"Git from the command line and also from 3rd-party software"
- 选择HTTPS传输后端:
- 选择"Use the OpenSSL library"
- 配置行尾符号转换:
- 选择"Checkout Windows-style, commit Unix-style line endings"
- 配置终端模拟器:
- 选择"Use MinTTY"
- 选择默认行为:
- 选择"Default (fast-forward or merge)"
- 选择凭据管理器:
- 选择"Git Credential Manager Core"
- 配置额外选项:
- 启用文件系统缓存
- 完成安装
基本配置
- 打开Git Bash
- 配置用户信息:
git config --global user.name "你的姓名"
git config --global user.email "你的邮箱"
- 配置文本编辑器(可选):
git config --global core.editor "code --wait" # 如果使用VS Code
- 查看配置信息:
git config --list
验证安装
git --version
常用配置(可选)
- 配置别名简化常用命令:
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
- 启用颜色显示:
git config --global color.ui auto
- 配置换行符处理(防止警告):
git config --global core.autocrlf true
注意事项
- 内网环境下无法使用GitHub等在线服务,但可以使用本地仓库或内网Git服务器
- 如需使用SSH密钥认证,需要在Git Bash中生成SSH密钥对:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
- 如需使用代理访问内网Git服务器,可配置:
git config --global http.proxy http://proxy.example.com:8080
完成以上步骤后,您已成功在内网Windows系统上安装并配置了Git。