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會檢查更新導致下載較慢,國內用戶可以配置鏡像源。否則會像下圖一樣卡住不動然后失敗。
更換鏡像源
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
常見問題
-
卡在
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
?文件夾重新拉取
- 之前拉取了 repo 但是不完整,需要刪除?