Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| git_clone [2019/03/15 09:53] – [Shallow clones] rpjday | git_clone [2019/03/16 10:40] (current) – [Shallow clones] rpjday | ||
|---|---|---|---|
| Line 54: | Line 54: | ||
| < | < | ||
| $ git clone --depth 1 --single-branch <repo URL> | $ git clone --depth 1 --single-branch <repo URL> | ||
| + | </ | ||
| + | |||
| + | From [[https:// | ||
| + | |||
| + | < | ||
| + | Side note: there' | ||
| + | promisor) but I still haven' | ||
| + | here, but I think we should eventually have some examples/ | ||
| + | |||
| + | A shallow clone is basically a repository with commit history cut | ||
| + | short. If you have a commit though, you have full content. It's not | ||
| + | cut by paths or anything. | ||
| + | |||
| + | "git clone --depth=X" | ||
| + | repository where all branches and tags have maximum X commits deep. | ||
| + | But since the main purpose of shallow clone is redude download, | ||
| + | --single-branch is made default when --depth is present, so you get | ||
| + | the default branch instead of all the branches (you would need | ||
| + | --no-single-branch for that). You could see these cut points with "git | ||
| + | log --decorate" | ||
| + | |||
| + | Once you have made a shallow clone, you could do everything like | ||
| + | usual. Local operations of course can only reach as far as the cut | ||
| + | points. Pull and push to a full clone are possible (it's even possible | ||
| + | to do so to another shallow clone). | ||
| + | |||
| + | When you "git fetch", | ||
| + | recent commits and the history depth increases. If you do "git fetch | ||
| + | --depth=X" | ||
| + | maximum X commits deep for all select branches, the same way a shallow | ||
| + | clone is made initially. "git fetch --unshallow" | ||
| + | shallow clone into a complete one. And I'm pretty sure you could turn | ||
| + | a complete one to shallow with "git fetch --depth" | ||
| + | |||
| + | While --depth works fine most of the time, sometimes you want a | ||
| + | different way to define these shallow/cut points. --shallow-since and | ||
| + | --shallow-exclude are added as the result. --shallow-since cut the | ||
| + | history by a specific date (for all select branches). | ||
| + | --shallow-exclude cuts the history by a ref (often a tag). As I | ||
| + | mentioned before, it's mostly used to say "I want a shallow clone from | ||
| + | (but not including) v2.9.0" | ||
| + | |||
| + | And I think that's pretty much it. There' | ||
| + | I can't remember when that's needed. Shallow clones may also prevent | ||
| + | you from using some optional features. Pack bitmap is one of those and | ||
| + | I think probably commit graph too. It's not technical limitation, just | ||
| + | lack of time/effort to support them in shallow clones. | ||
| + | -- | ||
| + | Duy | ||
| </ | </ | ||