Too slow to access github? I wrote an open source gadget to make it faster with one click

foreword

GitHub should be the most frequent site for developers. There are a large number of excellent projects, and it is a good place for developers to find resources, make friends and learn. In particular, some time ago, GitHub announced a code archiving plan-Arctic Code Vault, which will bury the code in a permafrost 250 meters deep underground, which can save the code for a thousand years. In addition, GitHub has designed commemorative badges for developers in configuration files.

Isn't it a little proud to think that your code can be preserved for a thousand years as a technological treasure of mankind.

well, let's get back to business.

Although GitHub has not been queried, because the CDN servers are all abroad, the speed of accessing GitHub in China is really slow, and sometimes the page cannot be refreshed, which has added many obstacles to my way of acquiring knowledge.

So, I worked hard for 3 hours and wrote a small tool to speed up GitHub access speed without using a trick, and I will share it with you in the end.

At the same time, this article will share other ways to speed up GitHub access. It is a relatively complete arrangement.

Let's get it!

A gadget that automatically generates the fastest access host

There are actually many reasons for the slow access speed of GitHub in China, but the main reason is that GitHub's distribution acceleration network domain name is polluted by DNS. In order to solve this problem, there are many articles on the Internet that provide a solution, that is, by modifying the Hosts file, bypassing the domestic DNS resolution, and directly accessing the CDN node of GitHub, so as to achieve the purpose of acceleration.

But I read most of the introductions about this method, only 3 related domain names of github are provided, and you need ipaddress.comto check them one by one. According to the ip found, go to ping yourself, select the fastest ip with the naked eye, and edit it into IP+ Domain name format, paste it into the hosts file.

In fact, GitHub uses a lot of related domain names. I sorted them out. There are more than a dozen in total.

github.global.ssl.fastly.net
github.com
assets-cdn.github.com
documentcloud.github.com
gist.github.com
help.github.com
nodeload.github.com
codeload.github.com
raw.github.com
status.github.com
training.github.com
avatars0.githubusercontent.com
avatars1.githubusercontent.com
avatars2.githubusercontent.com
avatars3.githubusercontent.com

It would be very troublesome to check and select one by one.

To this end, I wrote a tool that can automatically find the fastest CDN node corresponding to these dozen domain names according to your current IP. If one IP corresponds to multiple CDN nodes, the tool will automatically help you to ping 10 times. Get the IP address of the CDN with the smallest average.

All you need to do is paste the final generated result into your hosts file.

This gadget, follow "Yuanren tribe" and enter github to get it.

The usage is very simple, just need to execute the following command to run

java -jar githubhost.jar

After running, the browser input 127.0.0.1:8880can be automatically analyzed according to your current IP:

The analysis takes about ten seconds, and the progress bar will automatically refresh. After the progress bar is full, you can see the generated content:

Each operator in each region may run differently, so after getting the result, you can append this content to your hosts file (if you don't know where the hosts are stored, you can baidu yourself), and then follow the prompts Make the hosts file take effect.

The access address of the CDN is specified, so that your github access can be at least free of lag.

Code Cloud GitHub Mirror Station

Code Cloud provides a "Code Cloud Quick Download" station, which synchronizes some projects from github every day.

https://gitee.com/mirrors

Personally, I feel that not all github projects will be synchronized, depending on the number of warehouses, there are about 15k projects

If you want to clone some projects to study, you can check here first. Because Codeyun is a domestic open source project site, there is no need to worry about the speed of git clone, but it is a pity that

1. This mirror site is not all github projects, but most popular projects will have

2. There are no issue and release packages, only code

3. One day delay. i.e. what you see is the project status from a day ago

4. Because it's not github, you can't push this project to github

GitHub mirror site

This mirror site is:

https://github.com.cnpmjs.org/

After entering, it is completely no different from github, and the access is also very fast.

Especially the clone code, that's fast. . .

For example, if you originally wanted to clone, write

git clone https://github.com/kubernetes/kubernetes.git

Now change it to:

git clone https://github.com.cnpmjs.org/kubernetes/kubernetes.git

try it:

At this speed, there should be no desire. . .

Unfortunately, this method is:

1. This mirror site is very unstable, you will often see:

2. You need to modify the url yourself every time you clone, which is a bit inconvenient

3. You still can't push

GitClone site

On the way to find a solution, I found another site: gitclone

https://gitclone.com/

This is a GitHub cache acceleration node, which also caches about 15k projects, but gitclone has made a separate site, which can search for projects and even create repositories.

gitclone's clone provides multiple ways to clone

However, the final view of the searched project still jumps to the corresponding page on GitHub.

So in fact, it is similar to the gitee mirror station. Change the soup or not, the problem is similar to the previous mirror sites, but if you just want to clone, it is still a good choice.

Summarize

In fact, without the use of T-subs, there are only two ways:

  1. Modifying hosts to directly access the fastest CDN node has the advantage of being authentic.
  2. By mirroring to access and clone, the advantage of this method is the speed of clone.

Personally recommend that if you mainly browse, you should use the tools recommended above to generate hosts for configuration. After all, if you are authentic and clone large projects, you can consider the above mirror sites to speed up the download.

Follow the author

Finally, share this open source tool with everyone, follow the "Yuanren Tribe" public account, and reply to github to get the tool jar package. After startup, it can be automatically generated by accessing the 127.0.0.1:8880 port.

A technology sharing account that insists on being original. I hope you can pay attention to me. I will publish a practical original technology article every week. I will walk with you and no longer be afraid.

img

{{o.name}}
{{m.name}}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324129064&siteId=291194637