Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial (and shallow) clone note #1611

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions book/02-git-basics/sections/getting-a-repository.asc
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,22 @@ $ git clone https://github.com/libgit2/libgit2 mylibgit

That command does the same thing as the previous one, but the target directory is called `mylibgit`.

[NOTE]
.Partial and shallow clone
====
Git version 2.22 and later introduce the `--filter` option to `git clone`, which creates a _partial clone_.
Beside that, you can also get a _shallow clone_ by specifying the `--depth` option.

Partial and shallow clones can be useful in some situations, like when you're cloning an extremely large repository or cloning over a metered connection.
The benefit of doing a partial or shallow clone is that the clone takes up less size on disk.
The drawback is that a partial or shallow clone breaks the normal behavior of Git.

If you don't want to deal with this complexity, just do a normal (full) clone (`git clone` without `--filter` or `--depth` options).

We won't discuss partial and shallow clones in depth here, as these clones are for advanced users.
Please see the https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/[GitHub blog post about getting up to speed with partial clone and shallow clone^] and the https://docs.gitlab.com/ee/topics/git/partial_clone.html[GitLab documentation about partial clone^] for more information.
====

Git has a number of different transfer protocols you can use.
The previous example uses the `https://` protocol, but you may also see `git://` or `user@server:path/to/repo.git`, which uses the SSH transfer protocol.
<<ch04-git-on-the-server#_getting_git_on_a_server>> will introduce all of the available options the server can set up to access your Git repository and the pros and cons of each.