[Experience] Git|Linux terminal git is too slow, change hosts, copy folders, use mirror source? no no no no no

  A classmate asked me what to do if I want to clone a warehouse under Linux, and sent me a word to record his operation. After reading it, my blood pressure went up, so I remembered it.

  The following is divided into two situations, cloning one or two warehouses, and cloning a large number of warehouses.

1. Only one or two warehouses need to be cloned

  There are so many solutions to this situation, here are some commonly used ones (in order of practicality):

1 Import into Gitee

  For commonly used warehouses, import directly from the URL. The schematic diagram is as follows, which is to create a new warehouse and import it from the URL to get the gitee access link , thereby speeding up cloning.

insert image description here

2 Download the zip first, and then share it in the past

  No matter it is gitee, github or gitlab, there is a direct option on the webpage Download ZIPto avoid file errors before migration due to different systems.

insert image description here
  After downloading, transfer it directly through the shared folder of the virtual machine (if it is not a virtual machine, use a USB flash drive or other peripherals), or just drag it there.

It is also possible to use xftp or other file transfer tools, but I personally find it a bit troublesome.

  Note: Under Linux, decompress again!

Dragging the folder directly may cause an exception because Windows will add an EOF (End Of File) symbol after the file, but Linux will not.

  As for why web pages can be accessed on Windows, but not on Linux, it is because of the network on the one hand, and on the other hand, it is possible that Linux does not have a desktop system and no browser installed.

3 mirror source

  Replace github.comor gitlab.comreplace the warehouse that needs to be cloned with the current domestic mirror station. The mirror hub.fastgit.orgstation has already been hung up in my junior year, so the unreliability of this method can be seen. I have never looked for a new mirror station.

  You can also find a mirror station temporarily, pay attention to setting the search time of the search engine . It is best to limit it to within 1 year and find the latest available mirror station. Now 2023/2/17, very easy to use such as: ghproxy.com, URL and instructions see: https://ghproxy.com/ .

Notice

  It should be pointed out that the git repository cloned in the above two ways will not modify the git link of the files in the git repository. So suppose this warehouse references other warehouses as submodules , or the initialization of this warehouse needs to clone other warehouses , which means that a bunch of libraries need to be cloned! It does not apply to the above method, please read below.

Second, you need to clone a lot of libraries

  First of all, it can be explained that changing hosts is generally useless.

  First, the problem to be solved is that github and gitlab cannot be accessed. Why do we think that the dns server traversal and iterative analysis cannot be accessed, but the ip addresses of github and gitlab that we searched on the Internet can be accessed?
  Second, the articles of netizens and us are in a dislocation time and space. Why do we think that we can access the ip addresses that netizens can access in our region and at the current time?
  Third, if you really come across an accessible ip address, don’t you have to keep looking for new ones if the clone fails halfway?
  Fourth, even if we are not afraid of trouble, why should we believe that we know how to change hosts and refresh the dns cache?

  So if there are really a lot of libraries to clone, let's get a "network".

  Next, I will only introduce why the git of the terminal that has been connected to the "network" is still very slow .

Linux terminal git is too slow

  I believe that those who read this step are all Linux webpages that have been able to access github and gitlab normally (cast a look that understands), but they still can't clone.

  Let me start with a conclusion: the Linux terminal needs to be reconfigured.

  The configuration method is as follows: In ~/.bashrc, change the ports of https and http to your http port, change ftp to your socks port, and then restart the terminal.

sudo gedit ~/.bashrc
export https_proxy=http://127.0.0.1:8889 
export http_proxy=http://127.0.0.1:8889 
export ftp_proxy=socks5://127.0.0.1:1089
git config --global http.https://github.com.proxy http://127.0.0.1:8889

End: My suggestion is, if you can access github and gitlab, don't search for solutions on this website, and search on the wider Internet! You will find that the tutorials are really quite detailed.

Guess you like

Origin blog.csdn.net/qq_46106285/article/details/128914165