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

GIT具体配置步骤详解_第1张图片

常见问题

  • 卡在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 文件夹重新拉取

你可能感兴趣的:(全志-工具&测试,全志-FAQ,elasticsearch,数据库,大数据)