rogerxu / git-tips

Tips for Git
Apache License 2.0
2 stars 3 forks source link

Partial Clone #32

Open rogerxu opened 6 years ago

rogerxu commented 6 years ago

Git - git-clone Documentation

How to manage big Git repositories

Partial clone with Git and Mercurial - Stack Overflow

rogerxu commented 6 years ago

No Tags

$ git clone --no-tags <repository>

.git/config

[remote "origin"]
    url = https://xxx/xxx.git
    tagOpt = --no-tags
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
rogerxu commented 6 years ago

Shadow Clone

$ git clone --depth 10 <repository>
rogerxu commented 6 years ago

Single Branch

Clone a Branch

Clone master branch

$ git clone <repository> --single-branch

Clone a specific branch

$ git clone <repository> --branch <branch>

Fetch a Branch

Git - git-fetch Documentation

$ git fetch --depth=10 origin master
$ git fetch --depth=10 origin refs/heads/master:refs/remotes/origin/master
rogerxu commented 6 years ago

Sparse Checkout

$ git config core.sparsecheckout true
$ echo src/ > .git/info/sparse-checkout
$ git read-tree -m -u HEAD
rogerxu commented 5 years ago

Specific Revision

android - how to git clone with specific revision and depth=1 - Stack Overflow

Branch / Tag

If revision is a branch (refs/heads/xxx) or a tag (refs/tags/xxx),

$ git clone -b $revision --depth=1 $repository
$ git fetch --depth=1 $repository $revision
$ git checkout FETCH_HEAD

Commit

If revision is a specific commit or a ref under other namepaces, not refs/tags/ or refs/heads/,

$ git fetch --depth=1 $repository $revision
$ git checkout FETCH_HEAD
rogerxu commented 4 years ago

Partial Clone

Git - partial-clone Documentation Partial Clone for Large Repositories | GitLab

$ git clone --no-checkout --filter=blob:none <repository>