This article is a mirror article of machine translation, please click here to jump to the original article.

View: 3817|Reply: 4

Download large projects using Git shallow clone source code

[Copy link]
Posted on 2/19/2023 6:42:56 PM | | | |
Requirements: Using git's clone command, the source code and change history of the project will be cloned to the local disk by default, if the project file is updated and iterated frequently, we will download a lot of history, if we just want to consult and learn the latest source code, we only need to download the latest code on demand.


Clone an entire repository is a standard operating procedure using Git. Each clone typically includes everything in the repository.
This means that when cloning, you get not only the file, but also every revision of every file that has ever been committed, as well as the history of each commit. And if you have a lot of assets in your codebase, it will contain a long history. The main problem is that this creates bottlenecks in the continuous integration (CI) pipeline.
Check out the optimization projects of the codebase such as github.com, often need to complete the cloning of the code, the more star-studded the project, the larger the amount of code, the longer the history, in the case of poor domestic network, often download a few GB after downloading, the network is disconnected. Once interrupted, it cannot be continued, and it has to start from scratch, which is miserable.


Git shallow clone

We only clone the latest commit record with the following command:

-- depthRepresents the depth of the clone,-- depth 1 means that it only clones the latest commit record and the latest content after this commit, and does not clone the history commit, which has the effect of not being able to view the historical commit record, but the cloning speed is greatly improved.

Clone the latest source code + history as follows:



Clone only the latest source code, as follows:



(End)




Previous:Post-robot example of browser window communication
Next:PDF.JS Preview PDF files Chinese no issues are shown
 Landlord| Posted on 2/19/2023 6:43:59 PM |
Posted on 2/20/2023 10:59:31 AM |
Learn to learn
 Landlord| Posted on 10/6/2023 11:03:45 AM |
GitHub uses the REST API to view repository sizes
https://www.itsvse.com/thread-10674-1-1.html
 Landlord| Posted on 6/12/2025 11:15:41 AM |
Git Full Clone Project Repository (Image Repository)
https://www.itsvse.com/thread-11024-1-1.html
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com