Details git clone --depth = 1 Usage

To warehouse https://github.com/labuladong/fucking-algorithm an example
detailed demonstration of git clone --depth=1usage

I.: git clone

git clone https://github.com/labuladong/fucking-algorithm

Use git visual command git log --graph --oneline --allall the historical view warehouse commit record (I use the alias alias take GLog )

Description : The general warehouse document is not, we can use this method git clone warehouse, but the problem is that sometimes, in the historic warehouse when a particular commit, someone accidentally submitted the documents 1G, although in the latter commit him to delete this file, but still in the .git folder stores this file, so if we clone this warehouse warehouse, will All historical collaborative record clone down , so that the entire file will be very large, in fact, for people we directly use the warehouse, rather than participating in the warehouse, as long as the most recent commit to clone down just fine. It's like there are many versions of a product, we just clone the most recent version to use on the line. Achieve this you need to use the command git clone --depth = 1

Case 2: git clone --depth = 1

git clone --depth 1 https://github.com/labuladong/fucking-algorithm.git

Last commit
Description : You can see the last commit that contains a branch of our cloned, so the project files will not be great

And if we want to just clone a specified branch of a recent commit, you can use the following command

git clone --depth 1  --branch english https://github.com/labuladong/fucking-algorithm.git

enligh branch last commit

Summary :

  • The benefits of using git clone --depth = 1 is to limit the depth of the clone will not download Git history of collaboration, which can greatly accelerate the speed of cloning
  • cloning depth specifies the depth of 1 means that the last commit cloned
  • Suitable for use git clone --depth = 1 scenario: You just want to clone the latest version to use or learn, rather than participate in the development of the entire project

git clone --depth after pulling the other branches Method 1 =

enligh branch last commit
git clone --depth = 1 The above-mentioned operation only a clone branch Dictionary Dictionary English, if we want other remote branches (e.g., master) was also cloned into local, we need the following command

$ git remote set-branches origin 'remote_branch_name'
$ git fetch --depth 1 origin remote_branch_name
$ git checkout remote_branch_name


Reference document:
git clone some of the problems --depth = 1

Published 308 original articles · won praise 149 · Views 150,000 +

Guess you like

Origin blog.csdn.net/qq_43827595/article/details/104833980