GIT具体配置步骤详解

GIT配置具体步骤如下

SDK 使用 Repo 工具管理,拉取 SDK 需要配置安装 Repo 工具。

Repo is a tool built on top of Git. Repo helps manage many Git repositories, does the uploads to revision control systems, and automates parts of the development workflow. Repo is not meant to replace Git, only to make it easier to work with Git. The repo command is an executable Python script that you can put anywhere in your path.

Repo官网:git-repo

安装 Repo 工具

可以用包管理器进行安装:

# Debian/Ubuntu.
$ sudo apt-get install repo

# Gentoo.
$ sudo emerge dev-vcs/repo

也可以手动单独安装:

$ mkdir -p ~/.bin
$ PATH="${HOME}/.bin:${PATH}"
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo
$ chmod a+rx ~/.bin/repo

国内镜像源安装:

$ mkdir -p ~/.bin
$ PATH="${HOME}/.bin:${PATH}"
$ curl https://mirrors.bfsu.edu.cn/git/git-repo > ~/.bin/repo
$ chmod a+rx ~/.bin/repo

由于谷歌服务器位于国外,每次运行时Repo会检查更新导致下载较慢,国内用户可以配置镜像源。否则会像下图一样卡住不动然后失败。

8d60364e-7c3d-42a9-88e8-40778344fee1-image.png

更换镜像源

Repo 的运行过程中会尝试访问官方的 git 源更新自己,更换镜像源可以提高下载速度。将如下内容复制到你的~/.bashrc 里

$ echo export REPO_URL='https://mirrors.bfsu.edu.cn/git/git-repo' >> ~/.bashrc
$ source ~/.bashrc

如果您使用的是 dash、hash、 zsh 等 shell,请参照 shell 的文档配置。

配置保存身份认证

新版本 git 默认加强了安全性,身份认证不会保存,导致拉取 repo 需要多次输入密码,可以用下列命令配置:

git config --global credential.helper store

20c115a9-6a4c-40cc-8b35-9d70bc65974e-image.png

常见问题

  • 卡在Downloading Repo source from https://gerrit.googlesource.com/git-repo 不动。

    • 国内网络较慢,参照上面的更换镜像源解决。
  • 配置保存身份认证无效不启用

    • 检查是否运行了 sudo git config --global credential.helper store 使用了 sudo 后保存的信息会存储到 root 用户下并非当前用户。
  • 出现错误 fatal: cannot make directory: File exists

    • 之前拉取了 repo 但是不完整,需要删除 .repo 文件夹重新拉取

相关推荐

  1. docker swarm 详细安装配置步骤

    2023-12-23 14:52:02       14 阅读
  2. 实用攻略——SD-WAN网络配置步骤详解

    2023-12-23 14:52:02       46 阅读

最近更新

  1. TCP协议是安全的吗?

    2023-12-23 14:52:02       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-23 14:52:02       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-23 14:52:02       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-23 14:52:02       18 阅读

热门阅读

  1. 使用xuggle_5.4 实现视频加水印

    2023-12-23 14:52:02       38 阅读
  2. mockito-study-api

    2023-12-23 14:52:02       36 阅读
  3. Mac[M1]安装mongodb

    2023-12-23 14:52:02       33 阅读
  4. 掌握 Rust 中的建造者模式

    2023-12-23 14:52:02       46 阅读
  5. Harmonyos系统使用http访问网络和应用数据管理

    2023-12-23 14:52:02       31 阅读
  6. 数据处理演进:EtLT崛起,ELT正在告别历史舞台

    2023-12-23 14:52:02       33 阅读
  7. Golang leetcode59 螺旋矩阵

    2023-12-23 14:52:02       34 阅读
  8. 基于汉宁窗FIR滤波器实现语音信号加噪去噪

    2023-12-23 14:52:02       41 阅读
  9. MySQL数据库

    2023-12-23 14:52:02       32 阅读
  10. 理解计算机中的中断与中断处理

    2023-12-23 14:52:02       45 阅读
  11. log4j rename方法

    2023-12-23 14:52:02       35 阅读
  12. python使用selenium无法获取frame完整内容的问题

    2023-12-23 14:52:02       45 阅读
  13. 基于模板匹配的花朵分类 - MATLAB代码实现

    2023-12-23 14:52:02       36 阅读