0

I've tried every way I can find online but I just can't make this work. I have multiple repositories in Github which leverage actions. And by multiple I mean pushing 1K (not mine actually, but long story). I need to retrieve only the /.github folder and all of the files in it, I don't want the entire repository. I need to scan the workflows and actions YAML files to get a sense of what these are actually doing, like building code, testing, building and testing, etc. Could someone PLEASE help me with this, the sparse checkout just doesn't seem to work.

Thanks!

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
Richard Wolford
  • 353
  • 2
  • 15
  • 1
    https://unix.stackexchange.com/questions/233327/is-it-possible-to-clone-only-part-of-a-git-project – Daniel Mann Dec 03 '21 at 16:23
  • 1
    Does this answer your question? [How to sparsely checkout only one single file from a git repository?](https://stackoverflow.com/questions/2466735/how-to-sparsely-checkout-only-one-single-file-from-a-git-repository) – Daniel Mann Dec 03 '21 at 16:24
  • https://stackoverflow.com/a/13738951/7976758 , https://stackoverflow.com/a/52269934/7976758 , https://stackoverflow.com/a/2467629/7976758 – phd Dec 03 '21 at 16:52
  • Those links didn't help a lot, they were pretty old and I'm not looking to check out just a specific file, I need an entire folder as I don't know what files will be there. This seems to work but it is waaaaay too slow: mkdir test cd test git init git remote add origin https://github.com//.git git config core.sparseCheckout true echo ".github" >> .git/info/sparse-checkout git pull origin master The pull takes forever, is there a way to speed this up? – Richard Wolford Dec 03 '21 at 18:05
  • I'm sorry, I can't get my comment to put the commands I used on separate lines, even after following the formatting guide. – Richard Wolford Dec 03 '21 at 18:09
  • There is a new thing called a *partial clone*, but it's not ready for ordinary users. (As tricky as the sparse checkout stuff is, partial clone is considerably trickier, and requires sparse checkout too.) – torek Dec 04 '21 at 00:34

1 Answers1

0

If you want to do a partial "clone" of a repo, you can use sparse checkout:

# work folder
mkdir partialrepo
cd partialrepo

# new empty repo
git init

# point local repo at remote without cloning
git remote add origin https://pathtorepo

# enable sparse checkout
git config core.sparseCheckout true

# enumerate paths to check out
echo ".github" >> .git/info/sparse-checkout

# and pull them
git pull origin whateverbranchyouwanttopull

WaitingForGuacamole
  • 3,744
  • 1
  • 8
  • 22
  • I'm not sure what the echo statement does, I assume this is what tells it what is to be pulled? I thought there was a "set" statement or something similar? – Richard Wolford Dec 03 '21 at 16:35
  • it outputs the string to the console, which is redirected to that file path - the sparse-checkout file is a list of paths covered. – WaitingForGuacamole Dec 03 '21 at 16:44
  • Ah, okay gotcha. So question, if I run it as is, just echoing .github to the file, does that mean ".github and anything else below"? We'll need everything under .github, files, folders, subfolders, the works. – Richard Wolford Dec 03 '21 at 17:06
  • The -g option isn't working, git says it's an unknown option. I'm using git 2.34.1.windows.1 – Richard Wolford Dec 03 '21 at 17:12
  • And one last newbie question: this command: git pull origin master Results in `fatal: 'origin' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.` – Richard Wolford Dec 03 '21 at 17:20
  • I removed the -g. the script was fairly old, could have been deprecated, who knows - try the git remote add statement and the git pull statement again, please – WaitingForGuacamole Dec 03 '21 at 19:48