3

We have a repo with a bunch of projects. I am only concern with the "oracle" project within the repo. However, upon pulling down the codebase, I found subdirectories called "oracle" within other folders. Is there a way to only grab the parent folder that matches?

git init <repo>
cd <repo>
git remote add -f origin <url>

git config core.sparseCheckout true

echo "oracle/" >> .git/info/sparse-checkout

Output

#ls -l
  oracle
  directory123
  directoryabc

#find . | grep "oracle"
  directory123/sub1/sub2/oracle
  directoryabc/sub1/sub2/sub3/oracle
jub0bs
  • 60,866
  • 25
  • 183
  • 186
sdot257
  • 10,046
  • 26
  • 88
  • 122
  • 1
    If the `oracle` project is at the root of your repo, I've got a feeling that writing `/oracle/` instead of `oracle/` should do the trick. – jub0bs Apr 15 '16 at 15:47
  • Well damn that works! You can submit as an answer if you like and I will accept. – sdot257 Apr 15 '16 at 15:50

1 Answers1

5

By writing oracle/ to $GIT_DIR/info/sparse-checkout, you're telling your Git repo to only populate the working directory with files (if any) whose parent directory is called "oracle". Directories

oracle/
directory123/sub1/sub2/oracle/
directoryabc/sub1/sub2/sub3/oracle/

all satisfy this condition.

If you want to restrict the sparse checkout to the oracle directory that is at the root of your Git repo, you need to write, not oracle/, but /oracle/ (note the leading forward slash) to $GIT_DIR/info/sparse-checkout.

jub0bs
  • 60,866
  • 25
  • 183
  • 186