修改镜像源

979 阅读1分钟

源修改

一般逻辑:配置查看, 修改配置, 查找配置路径, 生效配置

pip 源修改

查看配置
pip config list

临时使用
pip install markdown -I https://pypi.tuna.tsinghua.edu.cn/simple

常见下载源
默认源 https://pypi.org/simple
清华源 https://pypi.tuna.tsinghua.edu.cn/simple

修改成清华源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

pip 配置路径
cd ~/.config/pip

Homebrew 源修改

homebrew git 镜像位置
cd "$(brew --repo)"

查看 homebrew git 源
git remote -v

修改 homebrew git 源
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

hombrew-core git 位置
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"

修改 homebrew-core 源
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

更新生效
brew update

替换 homebrew bottles 源

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile

更新生效 zshrc 环境变量配置
source ~/.zshrc

官方源(切回)
https://github.com/Homebrew/brew.git
ttps://github.com/Homebrew/homebrew-core.git

Git 修改源

1. 进入 git 仓库根目录

2. 查看 git 仓库源地址
git remote -v

3. 修改当前源地址
git remote set-url origin [GIT URL]

4. 添加新的 Git 库源地址 [NAME]为新的Git库源地址名,[GIT URL]为新的git库源地址
git remote add [NAME] [GIT URL]

5. 删除一个库源地址
git remote remove [NAME]

6. 一般操作
git commit -m "Change repo." # 先把所有为保存的修改打包为一个commit
git remote remove origin # 删掉原来git源
git remote add origin [YOUR NEW .GIT URL] # 将新源地址写入本地版本库配置文件
git push -u origin master # 提交所有代码

Ruby Gems 修改源

查看 gems 源
gem sources

修改源( 增加,移出)
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/

更新缓存
gem sources -u

gem sources 帮助
gem sources --help

npm 修改源

升级 npm
npm install -g npm

查看 npm 源
npm config get registry
默认的 npm 源为:https://registry.npmjs.org/

设置 npm 源
npm config set registry https://registry.npm.taobao.org

nrm 是 npm 源管理器, 安装
npm install -g nrm

查看源
nrm ls

切换源
nrm use taobao

添加源
nrm add registry http://192.168.10.127:8081/repository/npm-public/

删除源
nrm del <registry>

测试源性能
nrm test