Summary of methods to solve the problem of too slow GitHub download speed (continuously updated, recommended for collection)

foreword

The speed of downloading or cloning warehouses on Github is basically stable below 20k. When cloning some large warehouses, at this tortoise speed, it is easy to have a clone timeout error. After waiting for tens of minutes of downloading overnight and returning to before liberation, then I guess everyone has experienced this feeling more or less. This blog summarizes several available solutions for pro-testing, which greatly improves the download speed. A large warehouse can be completed in about a minute, and some new methods will be continuously updated. I hope it will be helpful to you.

The following solutions are all from the sharing of the Internet, I just make recommendations. Thanks to those selfless programmers.

1. Use git clone --depth=1 to download

If the file itself is too large, consider using:

git clone https://github.com/xxx --depth 1

https://github.com/xxx is the URL specifying the remote code repository to be cloned. The --depth 1 parameter indicates that only the latest commit (the default master branch) is cloned, rather than the history of the entire code repository being completely cloned. This reduces the amount of data downloaded and speeds up cloning operations.

If we want to clone only the latest commit of a specified branch, we can use the following command:

git clone  https://github.com/xxx --depth=1  --branch=xx_branch

The advantage of using git clone --depth=1 is to limit the depth of clone and not download the history of Git collaboration, which can greatly speed up the speed of cloning. depth is used to specify the cloning depth, if it is 1, it means only the latest commit will be cloned.

Suitable for using git clone --depth=1: you just want to clone the latest version to use or learn, instead of participating in the development of the entire project.

How to pull other branches after git clone --depth=1

cd xxx
git fetch --unshallow

This command is used to convert a shallow clone (shallow clone) of the code repository to a full clone (full clone). In shallow cloning, only the latest commit is cloned without the full history. The git fetch command is used to obtain the latest commit and branch information from a remote code warehouse. The --unshallow parameter tells Git to convert a shallow clone to a full clone, getting the full history. After executing this command, you will be able to access and manipulate the complete code repository.

Second, modify the host file to solve

Large-scale website servers will not have only one server, but a cluster of multiple servers to provide external services together.

Use the webmaster tool to measure the speed and find a faster server.

Please add a picture description

Please add a picture description
Then, put the string of the fastest IP address and Github domain name found just now at the end of the hosts file, with Mac /etc/hostsin and Windows in C:\Windows\System32\drivers\etc\hosts.

For example, the fastest IP address found on my computer is: 140.82.121.4 (the speed varies from place to place, subject to personal circumstances).

insert image description here
Finally, the DNS cache is flushed to apply the added mappings. Mac refreshes the DNS cache, enters in the terminal sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder, Windows refreshes the DNS cache, and executes in the cmd command window ipconfig /flushdns.

After executing these, you will find that the speed is significantly faster.

3. Google browser plug-in acceleration

For your browser, install a plugin [Github Acceleration].

Please add a picture description
After the installation is successful, open Github and you will see the following interface, with an additional acceleration button and acceleration address.

Please add a picture description

4. Greasy monkey plug-ins and scripts

For your browser, install a plugin [Tampermonkey].

Please add a picture description
Then install the Github enhancement script. After the installation is successful, there will be multiple acceleration addresses under the Code.

Please add a picture description

五、gitclone.com

This is the coolest and most comprehensive way I have ever used. https://gitclone.com is a code download website that provides download cache. It is very simple to use. You only need to add gitclone.com in front of the warehouse address to increase the speed several times.

For example, to clone the warehouse address on Github https://github.com/killer-p/ctool.git just change the address to https://gitclone.com/github.com/killer-p/ ctool.git​​, executed in the command line git clone https://gitclone.com/github.com/killer-p/ctool.git​​, the speed took off directly!

The working mechanism of gitclone is: when the developer clones the project through gitclone.com for the first time, gitclone.com asynchronously mirrors the project. When a developer clones the project in the future, it will use the local mirror of gitclone.com instead of clone from github.com. gitclone.com will sync with github.com every night. At present, gitclone.com has made a mirror image of all the star more than 1500. Through gitclone.com clone, if it can hit the mirror, the speed will reach more than 1M. If it has not been mirrored before, the mirror will be established with the git clone command, and it will be used in the next clone

6. Github accelerated download link

Website address: https://github.zhlh6.cn/ .

Copy the address of the Github warehouse, then paste it into the first column, and click Accelerate! Generate an acceleration address, use the acceleration address to download git clone, and the download speed can be increased to 1M at most.

Please add a picture description

7. Github mirror access

Github mirror is a website that is exactly the same as Github. It will synchronize resources on Github. Domestic access to Github mirror is faster, and you can also download the warehouse from the mirror. You can also use mirror when browsing Github. Anyway, it is faster, but the disadvantage is that you can’t Log in.

Mirror address: https://hub.fastgit.org

Note that this website cannot log in to the Github account, and clicking sign in will be blocked by the browser.

Eight, use code cloud download

Code Cloud itself supports one-click import of repo from Github and other code hosting websites, and then it will be very convenient to clone directly from Code Cloud.

The method of use is as follows: First, create a new warehouse in Code Cloud, and directly choose to import existing warehouses from other websites.

Please add a picture description
Copy the url of the warehouse, or directly choose to import the Github warehouse, as shown in the following figure:

Please add a picture description
After waiting for tens of seconds, Code Cloud pulls down the project on Github and puts it on the server of Code Cloud. At this time, we can download the warehouse from Code Cloud. Since the code cloud server is in China, the download speed is very fast.

References, thanks to the following articles

Github download speed is slow to improve github download speed The latest solution Say goodbye to turtle speed

A small coup to solve the problem that Github cannot be downloaded and the download speed is slow

Guess you like

Origin blog.csdn.net/a2360051431/article/details/130857622