0

I am having limited success with using git to clone a repo, then checkout a specific file and folder recursively. I have a repo setup like this

Repo root
|
|-FolderA     -scripts
|-FileA.yaml  -script input

There is a large amount of storage used by other files in this repo for development but I only need the script folder and 1 input file. I am running this from a fresh clean Linux environment as a step of a process that only needs to download the folder/file above not the other GBs of data.

My goal is to reduce the amount of data transferred in this process so that I can get the files at the time of the hash that more often are not be part of the commit the tag/hash is on.

What's the best wat to do this in bash on the cli with git?

Stephen Lester
  • 348
  • 3
  • 16
  • https://stackoverflow.com/search?q=%5Bgit%5D+clone+single+folder – phd Mar 02 '20 at 04:05
  • This is not helpful. I search for this question on this site already. There are similar ones but not exactly what I'm asking. – Stephen Lester Mar 02 '20 at 19:55
  • I want to clone only a single directory/file at the root. I only want git to download from the tagged branch the folder and the file. I don't want to clone any more than just the folder and file. a sparse checkout clones the whole repo. – Stephen Lester Mar 02 '20 at 22:20
  • I could get away with checking out a small branch the whole thing without an initial clone and checkout the 1 file at the root from the hash of the commit. Said commit may not include the file but I want the file contents at the time of the hash/commit. – Stephen Lester Mar 02 '20 at 22:21
  • https://stackoverflow.com/questions/600079/how-do-i-clone-a-subdirectory-only-of-a-git-repository/52269934#52269934 – Stephen Lester Mar 04 '20 at 21:18
  • I pointed to the question and all its answers. Did you miss the link at the top? – phd Mar 04 '20 at 21:37
  • No I pasted the link above as a reminder for me to follow back to that question as it may solve my issue. I have been tasked with another priority and will have to solve this later. – Stephen Lester Mar 05 '20 at 18:14

0 Answers0