Being an active participant in the development community, you might sometimes find yourself in situations where access to essential platforms like GitHub is restricted. As cumbersome as this may seem, there’s always a way around it. This article will tackle a popular and efficient method to circumvent this issue by configuring a Git HTTPS proxy.
Why Set Up a Git HTTPS Proxy?
Primarily, when we speak of GitHub blocks, it could result from network restrictions in your geographic region or company policy. A GIT HTTPS proxy enables you to bypass these restrictions and continue undisturbed development activities. Do note that if you’re cloning with HTTPS URLs, it’s crucial to configure the HTTPS proxy and not just the HTTP one.
So, let’s dive into the method and see how it works.
Setting Up Git HTTPS Proxy
Stage 1: Purchasing the Proxy
Many VPN providers are offering http/https proxy. Just My Socks (This is an affiliate link, please consider signing up through it to support our blog) is one of the great ones.
After you sign up, go to ‘Service Configuration’. Find and copy the following: Shadowsocks Password, Server IP address, and port number.
You may use V2RayN or Shadowsocks to set up HTTP proxy for your browser. Even with that, your git command line is very likely not working, as we need to set a proxy for git in the command line.
Stage 2: Setting the HTTPS Proxy in Git
Open a terminal and run the following commands to configure Git global settings. If you just clone a repository, you can just configure https proxy. Once again, if you only configure http proxy, you won’t be able to git clone as it uses https. Please note that you do not need to supply a username as you only have a password.
git config --global http.proxy http//:<shadowsocks-password>@<server_ip_address>:<proxy_port>
git config --global https.proxy http://<shadowsocks-password>@<server_ip_address>:<proxy_port>
Replace <>
with the corresponding values that you have copied from your Just My Socks configuration page.
Test the proxy settings: Run the following command to verify the proxy settings are correctly applied.
git config --global --get http.proxy
$ git config --global --get https.proxy
Cloning a Repository
With the HTTPS proxy now set, you can clone a repository in a regular way, even in areas where GitHub is blocked. Here’s how to do it:
git clone https://github.com/username/repository.git
A prompt will appear asking for your GitHub username and password if the repository is not public. Once you provide them, the cloning process will bypass any restrictions. You may also supply your GitHub username and personal token when cloning the repo. Please refer to our another blog to create a GitHub personal token if you do not know how to do it.
git clone https://github-username:personal-token@github.com/username/repository.git
Conclusion
Restrictions are only as strong as our will to overcome them. This comprehensive guide allows you to circumvent the issues and continue contributing to the open-source world.
Did this guide help you? Do you have any other tricks to bypass GitHub blocks? Share your thoughts in the comments below!
Please note: While this article aims to help you bypass certain restrictions, respecting laws and regulations in your region or organization is important.
[Disclaimer: The information in this blog post is for informational purposes only. You should not construe any such information as legal, tax, investment, financial, or other advice. The links in this blog might contain referrals.]
[Feature image is proudly generated by MidJourey]