Closed supereagle closed 7 years ago
对于已经git clone下来的项目,如果其还是使用HTTPS协议的话,是无法进行git pull
等操作的,同样提示port 443: Timed out
。可以将该项目的git协议由HTTPS修改为SSH。
$ cat .git/config
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[remote "origin"]
url = git@github.com:supereagle/kubernetes # Changed from `https://github.com/kubernetes/kubernetes.git`
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[user]
name = supereagle
email = jmyue@hotmail.com
手动修改项目的git config,需要在项目已经git clone下来之后才能进行。对于少量的项目,这种更改每个项目git config的方法还可以凑效。但是,对于大量项目的情况,这种方法就不可行了。尤其是Go的项目依赖非常多,而且都是通过go get
命令批量下载依赖。因此,必须采用修改git global config的方法,针对所有项目都生效。
在当前用户目录下新建文件.gitconfig,并添加如下内容:
$ cat /c/Users/robin/.gitconfig
[url "git@github.com:"]
insteadOf = https://github.com
或者直接通过git config --global
命令配置:
$ git config --global url."git@github.com:".insteadOf "https://github.com"
检查配置是否生效:
$ git config --list
core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
rebase.autosquash=true
http.sslcainfo=F:/Git/mingw32/ssl/certs/ca-bundle.crt
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.required=true
filter.lfs.process=git-lfs filter-process
pack.packsizelimit=2g
url.git@github.com:.insteadof=https://github.com # The added line
公司内部可以ping通外部网站,但是浏览器上网必须使用代理才能。因此,这个代理只是针对http,https等部分协议做了限制,而对其他协议是没有限制的,例如:ssh。