Answer by rsenna for How do I clone a subdirectory only of a Git repository?
In case you use fish, here you have a git clone-folder script based on Ciro Santilli's answer:#!/usr/bin/env fish# Based on https://stackoverflow.com/a/52269934/158074echoargparse -n='git clone-folder'...
View ArticleAnswer by halt9k for How do I clone a subdirectory only of a Git repository?
Seems no other answer combines:without cd (won't directly change active directory, but clones into subdirectory of active)creates .git in the target dirreadable (no packing into one...
View ArticleAnswer by adamz for How do I clone a subdirectory only of a Git repository?
#!/usr/bin/env bashset -eURL="$*"START=$(echo "$URL" | sed 's%/tree/main/%\n%g' | head -n1)END=$(echo "$URL" | sed 's%/tree/main/%\n%g' | tail -n1)FOLDER=$(echo "$END" | rev | cut -d'/' -f1 |...
View ArticleHow do I clone a subdirectory only of a Git repository?
I have my Git repository which, at the root, has two subdirectories:/finisht/staticWhen this was in SVN, /finisht was checked out in one place, while /static was checked out elsewhere, like so:svn co...
View ArticleAnswer by Jörg W Mittag for How do I clone a subdirectory only of a Git...
As of Git 2.19, this is finally possible, as can be seen in this answer.Consider upvoting that answer.Note: in Git 2.19, only client-side support is implemented, server-side support is still missing,...
View ArticleAnswer by hillu for How do I clone a subdirectory only of a Git repository?
If you never plan to interact with the repository from which you cloned, you can do a full git clone and rewrite your repository usinggit filter-branch --subdirectory-filter <subdirectory>This...
View ArticleAnswer by Chris Johnsen for How do I clone a subdirectory only of a Git...
Git 1.7.0 has “sparse checkouts”. See “core.sparseCheckout” in the git config manpage, “Sparse checkout” in the git read-tree manpage, and“Skip-worktree bit” in the git update-index manpage.The...
View ArticleAnswer by Chronial for How do I clone a subdirectory only of a Git repository?
What you are trying to do is called a sparse checkout, and that feature was added in Git 1.7.0 (Feb. 2012). The steps to do a sparse clone are as follows:mkdir <repo>cd <repo>git initgit...
View ArticleAnswer by david_adler for How do I clone a subdirectory only of a Git...
I wrote a script for downloading a subdirectory from GitHub.Usage:python get_git_sub_dir.py path/to/sub/dir <RECURSIVE>
View ArticleAnswer by ErichBSchulz for How do I clone a subdirectory only of a Git...
This looks far simpler:git archive --remote=<repo_url> <branch> <path> | tar xvf -
View ArticleAnswer by udondan for How do I clone a subdirectory only of a Git repository?
You can combine the sparse checkout and the shallow clone features. The shallow clone cuts off the history and the sparse checkout only pulls the files matching your patterns.git init <repo>cd...
View ArticleAnswer by kenorb for How do I clone a subdirectory only of a Git repository?
It's not possible to clone subdirectory only with Git, but below are few workarounds.Filter branchYou may want to rewrite the repository to look as if trunk/public_html/ had been its project root, and...
View ArticleAnswer by Anona112 for How do I clone a subdirectory only of a Git repository?
For other users who just want to download a file/folder from github, simply use:svn export <repo>/trunk/<folder>e.g.svn export https://github.com/lodash/lodash.com/trunk/docs(yes, that's...
View ArticleAnswer by jxramos for How do I clone a subdirectory only of a Git repository?
Here's a shell script I wrote for the use case of a single subdirectory sparse checkoutcoSubDir.shlocalRepo=$1remoteRepo=$2subDir=$3# Create local repository for subdirectory checkout, make it hidden...
View ArticleAnswer by Ciro Santilli OurBigBook.com for How do I clone a subdirectory only...
git clone --filter+git sparse-checkout downloads only the required filesE.g., to clone only files in subdirectory small/ in this test repository:...
View ArticleAnswer by BARJ for How do I clone a subdirectory only of a Git repository?
This will clone a specific folder and remove all history not related to it.git clone --single-branch -b {branch} git@github.com:{user}/{repo}.gitgit filter-branch --subdirectory-filter {path/to/folder}...
View ArticleAnswer by YenForYang for How do I clone a subdirectory only of a Git repository?
I wrote a .gitconfig[alias] for performing a "sparse checkout". Check it out (no pun intended):On Windows run in cmd.exegit config --global alias.sparse-checkout "!f(){ [ $# -eq 2 ] &&...
View ArticleAnswer by Nasir Iqbal for How do I clone a subdirectory only of a Git...
Using Linux? And only want easy to access and clean working tree ? without bothering rest of code on your machine. try symlinks!git clone https://github.com:{user}/{repo}.git ~/my-projectln -s...
View ArticleAnswer by expelledboy for How do I clone a subdirectory only of a Git...
While I hate actually having to use svn when dealing with git repos :/ I use this all the time;function git-scp() ( URL="$1"&& shift 1 svn export ${URL/blob\/master/trunk})This allows you to...
View ArticleAnswer by weberjn for How do I clone a subdirectory only of a Git repository?
If you're actually ony interested in the latest revision files of a directory, Github lets you download a repository as Zip file, which does not contain history. So downloading is very much faster.
View Article