Git sparse checkout to only honor a folder at the root of the repo?

萝らか妹 提交于 2020-01-04 05:41:30

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/36650640/git-sparse-checkout-to-only-honor-a-folder-at-the-root-of-the-repo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!