简体   繁体   中英

Git download only selected files in new branch

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.

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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM