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 
2
  • 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. Commented Apr 15, 2016 at 15:47
  • Well damn that works! You can submit as an answer if you like and I will accept. Commented Apr 15, 2016 at 15:50

1 Answer 1

6

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.