A huge code was migrated from VSTS to Git recently.My repo has huge amount as files. I want to download only selected folders in a new location. Is there anyway I can download only selected folders when new git repo is downloaded locally? VSTS has option where we can create workspace but don't download entire folders/files.
2 Answers
You can, but I'd say it's problem that will get worse over time. If the repo is too big to use then it's a bad repo :)
For single files you can check Retrieve a single file from a repository.
If you need files/folder from another project in your project you could also look at submodules.

- 31,798
- 8
- 86
- 126
-
thanks I am new to this as we have used VSTS for long time. Will try this. Part of the problem is our source code has lengthy folder structure because of naming conventions we followed.Git fails to download those files because of file name length. – Patri Oct 31 '19 at 20:41
Git doesn't provide a way to download only selected files or folders. There are some ways you can download less data, however.
You can try a clone of a single branch, which avoids downloading the history for other branches. If you want to download the master
branch, then use git clone -b master URL
.
You can do a shallow clone, which omits history beyond a certain point. This can dramatically reduce the amount of data you need to download, and you can pull down additional history if you need it. You can do this with git clone --depth 50 URL
to download the latest 50 commits.
If you don't need an actual repository, you can try the archive trick that tymtam mentioned, but be aware that most server implementations don't offer the git archive
operation over SSH, since they have their own archive implementations which implement caching. You can download an archive of just that revision using the web UI, however.
If your problem is that you want to have fewer files checked out, you can try sparse checkout, but be aware that it's very rough around the edges and requires using a lot of low-level commands, so if you're not very comfortable with Git and willing to read the documentation on it, I don't recommend it.

- 64,793
- 6
- 84
- 100
-
thanks I am new to this as we have used VSTS for long time. Will try this. Part of the problem is our source code has lengthy folder structure because of naming conventions we followed.Git fails to download those files because of file name length. – Patri Oct 31 '19 at 20:41