企业代理背后的 Git 克隆
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34988038/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git clone behind corporate proxy
提问by Giovanni Grano
I am working behind a corporate proxy, using a Windows 7 pc, and I would to use git hub, cloning some repo, doing pulls, commits and pushes.
我在公司代理后面工作,使用 Windows 7 pc,我会使用 git hub,克隆一些 repo,执行拉取、提交和推送。
I does not know the password of my proxy.
我不知道我的代理的密码。
I can regularly download a repo via the button "Download ZIP" but I would use GIT via command line or via GitHub client app.
我可以通过“下载 ZIP”按钮定期下载存储库,但我会通过命令行或 GitHub 客户端应用程序使用 GIT。
Thank you.
谢谢你。
Edit
编辑
The repository whichI am trying to clone is a private repository and I am a contributor.
我试图克隆的存储库是一个私有存储库,我是一个贡献者。
I receive the following message:
我收到以下消息:
*fatal: unable to access 'https:***.git/': Connection timed out after 300043 milliseconds*
*致命:无法访问“https:***.git/”:连接在 300043 毫秒后超时*
回答by CodeWizard
I does not know why I can regularly download the ZIP but I can't clone the repo. Why this difference?
我不知道为什么我可以定期下载 ZIP,但我无法克隆 repo。为什么会有这种差异?
Proxy is used to access the internet (which means to "go out" of your internal network). In your case is you can download ZIP
but on the same time you can't pull code from github it looks like you don't have the right permissions.
代理用于访问互联网(这意味着“走出”您的内部网络)。在您的情况下,您可以下载ZIP
但同时您无法从 github 中提取代码,看起来您没有正确的权限。
When you download ZIP you simply connecting to the internet and downloading file, while when connecting to git and trying to download code you need to use any of the git protocols.
当您下载 ZIP 时,您只需连接到 Internet 并下载文件,而在连接到 git 并尝试下载代码时,您需要使用任何git 协议。
Try to set up ssh key as described in the following answerand here.
Sumamry:
总结:
- If you can download files from the web you have an internet connection.
To set up git proxy configuration:
git config --global http.proxy http://user:[email protected]:8080 git config --global https.proxy http.proxy http://user:[email protected]:8080
- 如果您可以从 Web 下载文件,则您有 Internet 连接。
设置 git 代理配置:
git config --global http.proxy http://user:[email protected]:8080 git config --global https.proxy http.proxy http://user:[email protected]:8080
But in your case you don't know the password so you should first try to set ssh keys and check if it works.
但是在您的情况下,您不知道密码,因此您应该首先尝试设置 ssh 密钥并检查它是否有效。
回答by nobar
Given that the simple download works, it is likely that your computer is configured correctly for the proxy. You also need to make sure that the proxy configuration is shared with git on the command-line. This is usually done through environment variables such as http_proxy
and https_proxy
.
鉴于简单下载有效,您的计算机可能已为代理正确配置。您还需要确保在命令行上与 git 共享代理配置。这通常是通过环境变量完成的,例如http_proxy
和https_proxy
。
There are two options available when you click "Clone or download" to get the link. These are "Clone with HTTPS" and "Clone with SSH". In order to work with SSH keys, you need to use the "Clone with SSH" option.
单击“克隆或下载”以获取链接时,有两个选项可用。它们是“使用 HTTPS 克隆”和“使用 SSH 克隆”。 为了使用 SSH 密钥,您需要使用“Clone with SSH”选项。
The link provided for use with SSH has the following form: git@github.***.com:***.git
提供的用于 SSH 的链接具有以下形式: git@github.***.com:***.git
So to clone the repository, your command will look like:
因此,要克隆存储库,您的命令将如下所示:
git clone git@github.***.com:***.git
Also, make sure that you have copied the link correctly from the GitHub website. For example, the following intuitive translation from HTTPS may not work, and may instead respond with timeout errors similar to what was reported by the OP:
此外,请确保您已从 GitHub 网站 正确复制链接。例如,以下来自 HTTPS 的直观翻译可能不起作用,并且可能会响应类似于 OP 报告的超时错误:
git clone git://github.***.com/***.git ## wrong form
回答by DataFramed
Before running regular git commands, simply set proxy using below command.
在运行常规 git 命令之前,只需使用以下命令设置代理。
git config --global http.proxy http://user:[email protected]:8080
git config --global http.proxy http://user:[email protected]:8080