Quantcast
Channel: How do I clone a subdirectory only of a Git repository? - Stack Overflow
Browsing index pages (35 articles)

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 Article


Answer 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 Article


Answer 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 Article

How 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 Article

Answer 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 Article


Answer 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 Article

Answer 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 Article

Answer 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 Article


Answer 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 Article


Answer 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 Article

Answer 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 Article

Answer 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 Article

Answer 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 Article


Answer 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 Article

Answer 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 Article


Answer 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 Article

Answer 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 Article


Answer 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 Article

Answer 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 Article

Answer 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
Browsing index pages (35 articles)


Latest Images