git设置代理多账号
git代理设置
不建议
设置全局代理, 多环境下可能混乱- 注意使用协议,能使用
ssh协议
尽量使用ssh协议
方式 - 具体的代理ip和端口视情况调整,以下用端口
1080
示例
HTTP协议代理设置
1、使用命令直接设置代理
--global
表示全局,不需要可以不加
git config --global https.proxy ***
例子:
# socks
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'
# http
git config --global http.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080# 只对github.com使用代理,其他仓库不走代理
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080
git config --global https.https://github.com.proxy socks5://127.0.0.1:1080
# 取消github代理
git config --global --unset http.https://github.com.proxy
git config --global --unset https.https://github.com.proxy
2、直接修改~/.gitconfig
文件
[http]
proxy = socks5://127.0.0.1:1080
[https]
proxy = socks5://127.0.0.1:1080
3、取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy
SSH协议代理设置
修改ssh配置文件~/.ssh/config
没有的话新建一个文件
Windows
ssh配置文件路径:C:\Users\你的用户名\.ssh\config
Linux
ssh配置文件路径:/home/你的用户名/.ssh/config
ProxyCommand connect -S 代理地址:端口 %h %p
例子
# 全局
# ProxyCommand connect -S 127.0.0.1:1080 %h %p
# 只为特定域名设定
Host github.com gitlab.com
ProxyCommand connect -S 127.0.0.1:1080 %h %p
-S
代表走socks
代理。( -H
实现http和https的仓库的克隆)
多个地址设置:Host
后面使用空格隔开,而不是,
多账号设置
生成公私钥,并在对应账号配置公钥
// 生成两个邮箱对应的ssh公私钥
ssh-keygen -t ed25519 -C "1@email"
ssh-keygen -t ed25519 -C "2@email"
配置例子:
# Host:仓库网站的别名,随意取
# HostName:仓库网站的域名(PS:IP 地址应该也可以)
# User:仓库网站上的用户名
# IdentityFile:私钥的绝对路径
Host aa.github.com
Hostname ssh.github.com
Port 22
User aa
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_aa
ProxyCommand connect -S 127.0.0.1:1080 %h %pHost bb.github.com
Hostname ssh.github.com
Port 22
User bb
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_bb
ProxyCommand connect -S 127.0.0.1:1080 %h %p
测试:
$ ssh -vT git@仓库网站的别名
$ ssh -vT git@github.com
$ ssh -vT git@aa.github.com
$ ssh -vT git@bb.github.com
clone代码
git@仓库网站的别名:项目地址.git
使用多账号时,删除全局的配置,然后再项目下单独配置
删除全局的配置
git config --global --unset user.name
git config --global --unset user.email
git config --global --unset user.password
项目下配置
git config user.name "name1"
git config user.email "1@email"
之后再添加远程仓库的时候,就不能直接使用http
的方式了,只能使用ssh
方式.
git设置代理多账号相关推荐
- vmware Ubuntu虚拟机设置代理
1.虚拟机设置代理 打开Ubuntu的设置,并点击Network->Network Proxy选择Manual,并填写代理地址. 其中ip可以直接在主机上查看.要用VMware那个IP. 2.V ...
- GIT全局代理和局部代理
git设置代理模式,仅为github设置代理 设置代理:全局代理git config --global http.proxy 127.0.0.1:1087局部代理,在github clone 仓库内执 ...
- git设置和取消代理
git设置和取消代理 转载于 git 设置和取消代理 - 削微寒 - 博客园 # 设置ss git config -global http.proxy 'socks5://127.0.0.1:1080 ...
- go/git设置及取消代理方法
本地开启VPN后,GIt也需要设置代理,才能正常略过GFW,访问goole code等网站 设置如下(可复制): git config --global https.proxy http://127. ...
- git 加速代理设置,单仓库设置代理,指定仓库设置单独代理
1. git全局设置代理 git config --global https.proxy http://127.0.0.1:7890git config --global https.proxy ht ...
- git设置http和https代理
为什么80%的码农都做不了架构师?>>> 如果直连git遇到速度很慢,或者如果公司使用代理,git就需要设置代理才能克隆远程仓库 执行下面两条语句 git config --g ...
- 成功解决 git设置http代理 https代理 取消代理
welcome to my blog 问题: 使用hexo搭建博客, 执行hexo init时包含git clone的操作,但是使用的是https协议, 不是ssh, 所以为git设置https代理, ...
- GITHUB设置代理——解决git clone下载过慢的问题
1.引言 最近需要复现一篇论文的工作,该工作代码已经在github上开源了,开始采用网页界面下载压缩包的方式,但是发现该github项目内嵌套了其他github子项目,直接下载压缩包会导致子项目文件夹 ...
- git 重新设置代理
//首先,设置默认代理,也可以理解为清除代理 git config --global --unset http.proxy git config --global --unset https.prox ...
最新文章
- bellman_ford寻找平均权值最小的回路
- MySQL count(*)空表为何会很慢
- 转载非原创:修改BB 的内容,回车后修改CC 的值
- python unicode编码转换中文_python unicode转中文及转换默认编码
- zlib和openssl相关库错误的解决
- python编程入门指南上下百度云-Python编程入门指南(上下册)
- Python/WSGI 应用快速入门--转
- golang byte转string_Golang和Rust语言常见功能/库
- 浅谈JAVA中如何利用socket进行网络编程(二)
- c语言三个数从小到大排序/输出_我的c语言笔记(三)
- mongodb数据可视化_使用MongoDB实时可视化开放数据
- PHP 函数调用跟踪
- 解决http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar
- 手把手玩转win8开发系列课程(9)
- 盖世无双之国产数据库风云榜-2022年02月
- 惠普m1005mfp说明书_惠普M1005使用说明
- 澳大利亚域名_澳大利亚域名.au注册要求
- ChatGPT专业应用:撰写节日营销活动方案
- 抽象类 模板设计模式
- ANSYS APDL学习(8):选取全部的封闭曲面生成实体(体积)的命令流讲解