代码改变世界

内网Windows系统离线安装Git详细步骤 - 教程

2025-09-18 16:30  tlnshuju  阅读(408)  评论(0)    收藏  举报

下载离线安装包

  1. 在有互联网连接的计算机上访问Git官网下载页面:

    https://git-scm.com/download/win
  2. 下载"Standalone Installer"版本的Git安装程序(如Git-2.xx.x-64-bit.exe)

  3. 将下载的安装文件拷贝到内网Windows系统中

安装Git

  1. 双击运行Git安装程序
  2. 选择安装位置(默认即可)
  3. 选择组件(建议全选):
    • Git Bash
    • Git GUI
    • Git LFS
    • 关联.git文件等
  4. 选择开始菜单文件夹(默认即可)
  5. 选择默认编辑器(推荐选择Vim或VS Code如果已安装)
  6. 调整PATH环境:
    • 选择"Git from the command line and also from 3rd-party software"
  7. 选择HTTPS传输后端:
    • 选择"Use the OpenSSL library"
  8. 配置行尾符号转换:
    • 选择"Checkout Windows-style, commit Unix-style line endings"
  9. 配置终端模拟器:
    • 选择"Use MinTTY"
  10. 选择默认行为:
    • 选择"Default (fast-forward or merge)"
  11. 选择凭据管理器:
    • 选择"Git Credential Manager Core"
  12. 配置额外选项:
    • 启用文件系统缓存
  13. 完成安装

基本配置

  1. 打开Git Bash
  2. 配置用户信息:
git config --global user.name "你的姓名"
git config --global user.email "你的邮箱"
  1. 配置文本编辑器(可选):
git config --global core.editor "code --wait" # 如果使用VS Code
  1. 查看配置信息:
git config --list

验证安装

git --version

常用配置(可选)

  1. 配置别名简化常用命令:
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
  1. 启用颜色显示:
git config --global color.ui auto
  1. 配置换行符处理(防止警告):
git config --global core.autocrlf true

注意事项

  1. 内网环境下无法使用GitHub等在线服务,但可以使用本地仓库或内网Git服务器
  2. 如需使用SSH密钥认证,需要在Git Bash中生成SSH密钥对:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
  1. 如需使用代理访问内网Git服务器,可配置:
git config --global http.proxy http://proxy.example.com:8080

完成以上步骤后,您已成功在内网Windows系统上安装并配置了Git。