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 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 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,16 @@ $ 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 `--filter` option to `git clone`, which creates _partial clone_. Beside that, you can also get _shallow clone_ by specify `--depth` option.

While partial and shallow clones can be useful on some situations (such as when cloning extremely large repository and cloning over metered connection), these come with their own tradeoffs that break at least one expectation from normal distribute nature of Git. If you aren't willing to make these tradeoffs, just do normal (full) clone (`git clone` without `--filter` or `--depth` options).

We won't discuss further about partial and shallow clones, as these are for advanced users. Please see GitHub blog post at https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/ and GitLab documentation at https://docs.gitlab.com/ee/topics/git/partial_clone.html for complete discussion about these.
bagasme marked this conversation as resolved.
Show resolved Hide resolved
====

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.