Quantcast
Channel: How do I clone a subdirectory only of a Git repository? - Stack Overflow
Browsing latest articles
Browse All 32 View Live

Answer by Marinos An for How do I clone a subdirectory only of a Git repository?

(extending this answer )Cloning subdirectory in specific tagIf you want to clone a specific subdirectory of a specific tag you can follow the steps below.I clone the...

View Article



Answer by le_top for How do I clone a subdirectory only of a Git repository?

@Chronial 's anwser is no longer applicable to recent versions, but it was a useful anwser as it proposed a script.Given information I gathered and the fact that I wanted to checkout only a...

View Article

Answer by Evan MJ for How do I clone a subdirectory only of a Git repository?

2022 AnswerI'm not sure why there are so many complicated answers to this question. It can be done easily by doing a sparse cloning of the repo, to the folder that you want.Navigate to the folder where...

View Article

Answer by NeoZoom.lua for How do I clone a subdirectory only of a Git...

For macOS usersFor zsh users (macOS users, specifically) cloning Repos with ssh, I just create a zsh command based on the answer by @Ciro Santilli:requirement: The version of git matters. It doesn't...

View Article

Answer by Jaswinder for How do I clone a subdirectory only of a Git repository?

git init <repo>cd <repo>git remote add origin <url>git config core.sparsecheckout trueecho "<path you want to clone>/*" >> .git/info/sparse-checkoutgit pull --depth=1...

View Article


Answer by Abdul97j for How do I clone a subdirectory only of a Git repository?

It worked for me- (git version 2.35.1)git initgit remote add origin <YourRepoUrl>git config core.sparseCheckout truegit sparse-checkout set <YourSubfolderName>git pull origin...

View Article

Answer by Ilir Liburn for How do I clone a subdirectory only of a Git...

I don't know if anyone succeeded pulling specific directory, here is my experience: git clone --filter=blob:none --single-branch <repo>, cancel immediately while downloading objects, enter repo,...

View Article

Answer by Tal Jacob - Sir Jacques for How do I clone a subdirectory only of a...

If you want to clonegit clone --no-checkout <REPOSITORY_URL>cd <REPOSITORY_NAME>Now set the specific file / directory you wish to pull into the working-directory:git sparse-checkout set...

View Article


Answer by Parables Boltnoel for How do I clone a subdirectory only of a Git...

degit makes copies of git repositories. When you run degitsome-user/some-repo, it will find the latest commit onhttps://github.com/some-user/some-repo and download the associated tarfile to...

View Article


Answer by Friedrich -- СлаваУкраїні for How do I clone a subdirectory only of...

You can still use svn:svn export https://admin@domain.example/home/admin/repos/finisht/static static --forceto "git clone" a subdirectory and then to "git pull" this subdirectory.(It is not intended to...

View Article

Answer by Carson for How do I clone a subdirectory only of a Git repository?

here is what I dogit initgit sparse-checkout initgit sparse-checkout set "YOUR_DIR_PATH"git remote add origin https://github.com/AUTH/REPO.gitgit pull --depth 1 origin <SHA1_or_BRANCH_NAME>Simple...

View Article

Answer by Eric Stricklin for How do I clone a subdirectory only of a Git...

Lots of great responses here, but I wanted to add that using the quotations around the directory names was failing for me on Windows Sever 2016. The files simply were not being downloaded.Instead...

View Article

Answer by Mike Slinn for How do I clone a subdirectory only of a Git repository?

Lots of good ideas and scripts above. I could not help myself and combined them into a bash script with help and error checking:#!/bin/bashfunction help { printf "$1Clones a specific directory from the...

View Article


Answer by Patrick Simard for How do I clone a subdirectory only of a Git...

So i tried everything in this tread and nothing worked for me ... Turns out that on version 2.24 of Git (the one that comes with cpanel at the time of this answer), you don't need to do thisecho...

View Article

Answer by Everett for How do I clone a subdirectory only of a Git repository?

Just to clarify some of the great answers here, the steps outlined in many of the answers assume that you already have a remote repository somewhere.Given: an existing git repository, e.g....

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

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

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
Browsing latest articles
Browse All 32 View Live




Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>