Reputation: 30973
im looking for away to do clone as minimal as i can ,
so no source will be downloaded (checkout)
then after i done the "minimal clone"
i need to be able to do :
git branch -r
to list all repo branches
Then select branch from the list and checkout only 1 file from the selected branch
i really want to avoid downloading and updating all repo source code. In this example i want to get all the remote branches of "develop"
what i tried to do "minimal clone" is:
git clone --depth 1 --no-checkout https://user:[email protected]/foo/project.git
but then when i list the branches:
git branch -r
im getting :
origin/HEAD -> origin/develop
origin/develop
and when i checkout origin/develop im getting all the sources
but it does download me all the repo sources .
im using git version 2.10.2.windows.1.
Upvotes: 0
Views: 295
Reputation: 30966
Initialize a repo instead of creating it by git clone
,
git init project
cd project
git remote add origin https://user:[email protected]/foo/project.git
To list all the refs,
git ls-remote
If branches only,
git ls-remote --heads
Pick a branch, say develop
, and fetch its last commit only,
git fetch origin develop --depth 1
Config sparse-checkout
to checkout only 1 file, say path/to/foo.txt
,
git config core.sparsecheckout true
echo "path/to/foo.txt" >> .git/info/sparse-checkout
Checkout the only file,
git checkout develop
Upvotes: 2