Skip to content

Commit 42b4a3b

Browse files
y21jyn514
authored andcommitted
mention git clone --depth
1 parent 1fd8ddb commit 42b4a3b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Diff for: src/building/how-to-build-and-run.md

+21
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,27 @@ git clone https://github.com/rust-lang/rust.git
2424
cd rust
2525
```
2626

27+
### Shallow clone the repository
28+
29+
Due to the size of the repository, cloning on a slower internet connection can take a long time.
30+
To sidestep this, you can use the `--depth N` option with the `git clone` command.
31+
This instructs `git` to perform a "shallow clone", cloning the repository but truncating it to the last `N` commits.
32+
33+
Passing `--depth 1` tells `git` to clone the repository but truncate the history to the latest commit
34+
that is on the `master` branch, which is usually fine for browsing the source code or building the compiler.
35+
36+
```bash
37+
git clone --depth 1 https://github.com/rust-lang/rust.git
38+
cd rust
39+
```
40+
41+
> **NOTE**: A shallow clone limits which `git` commands can be run.
42+
> If you intend to work on and contribute to the compiler, it is
43+
> generally recommended to fully clone the repository [as shown above](#get-the-source-code).
44+
>
45+
> For example, `git bisect` and `git blame` require access to the commit history,
46+
> so they don't work if the repository was cloned with `--depth 1`.
47+
2748
## What is `x.py`?
2849

2950
`x.py` is the build tool for the `rust` repository. It can build docs, run tests, and compile the

0 commit comments

Comments
 (0)