Git 2.25.0 release, new features: some clone with sparse checkout

Git 2.25.0 release, project contributors Taylor Blau describes this version brings some of the highlights on features, including partial clone (partial clone) and sparse checkouts (sparse checkout).

partial clone, partial clone

In general, when Git clone copy will copy all of the data warehouse, including every version history of each file, for very large repositories, if only part of the file, and it will virtually increase network transmission and local cost of storage. In the past few releases, Git has the ability to perform part of the clone, which means it can now use cloning and repository without having to have all parts of the content.

Currently this feature is still in the experimental stage.

Specifically, part of the cloning requires the client to do two things: it must be able to tell the server only needs to which objects in the repository, but also must be able to not conflict with the lack of a complete set of objects of the local repository. On the other hand, the server must be able to explain the client's request, serve only certain objects, and can generate an appropriate response.

Which is the necessary logic needed Git receives the response and the server can skip detection repository , because once detected, it will not find a complete clone objects, and try to request to the server. In effect, this function is performed by another new feature: sparse checkout, sparse checkouts.

sparse checkout, sparse checkouts

Sparse checkouts is actually a file path pattern similar matches .gitignore list, tell Git repository at the time of detection of objects which can be skipped, it is a copy of the contents of the work object, rather than .gitignore is the index.

Sparse checkouts have a drawback is difficult to specify, for example, it is lower than or equal to the depth of detection to skip document 2:

$ git clone --filter=blob:none --no-checkout /your/repository/here repo
$ cd repo
$ cat >.git/info/sparse-checkout <<EOF
/*
!/*
EOF
$ git config core.sparseCheckout 1
$ git checkout .

First, specify --filter = blob: none requires the server to avoid sending blob to us, and then use the --no-checkout tells Git skip / your / repository / here in this part of the store when checking out, but it's actually much dependent on the  .git/info/sparse-checkoutmatching pattern.

Git 2.25 by introducing new git sparse-checkout command, make this operation easier. The following are the top the same function demo:

$ git clone --filter=blob:none --sparse /your/repository/here repo

This git sparse-checkoutcommand allows the user to easily perform as part of cloning and sparse checkouts without complex .gitignorepattern matching to write .git/info/sparse-checkout, git sparse-checkoutwill deal directly.

git sparse-checkout You can do four things: setting (set) a list of paths to be checked out, print (list) list of current and fully enabled (enable) or disable (disable) sparse checkouts.

To check out a new path, simply execute the following command:

$ git sparse-checkout set /path/to/check/out

In addition, a very large warehouse, sparse checkouts pattern matching list would be too complicated, Git now offers a cone mode, perform git config core.sparseCheckoutConethis mode, allowing pattern matching sets will become more stringent, you can specify whether directly to the stator all paths detected or all files within the directory rather than .gitignore by pattern matching.

For example, if there is a directory A / B / C in a large store, and C is usually most of the work position, it may need to be completely detected, but detection of the A and B need to let enough content, so that it can reach C. In the cone mode,  git sparse-checkout set A/B/C you can do it.

About Git 2.25 update, and view details:

Guess you like

Origin www.oschina.net/news/112802/git-2-25-0-released