Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Git Sparse Checkout #636

Open
jplindquist opened this issue Apr 24, 2024 · 0 comments · May be fixed by #637
Open

Enable Git Sparse Checkout #636

jplindquist opened this issue Apr 24, 2024 · 0 comments · May be fixed by #637

Comments

@jplindquist
Copy link

Use Case

There is a somewhat common pattern of using monorepos across a variety of orgs, and it's not always necessary (or desirable) to have all of the code checked out for each component. Git allows for sparse checkouts where you can specific files, paths, etc to checkout and track vs. the entire repo.

Describe the Solution You Would Like

I would love for the vcsrepo git type to suppport sparse checkouts. I saw that the feature is enabled for svn currently. The git documentation to use the specific subcommand would require a newer version of git (>= 2.25 iirc), but supports other methods of accomplishing this in earlier versions of the client.

Describe Alternatives You've Considered

We can checkout the full repo as is if needed, but it is undesirable in certain scenarios where multiple applications might share a single repo when they're deployed to different places or in different ways.

Additional Context

Samples:

With a directory structure such as the following:

  mymodules/
   python-module/
     __init__.py
     module.py
   go-module/
     main.go
     go.mod
     go.sum

If I wanted to clone only the python-module directory, I would do the following:

Using Newer Version of Git

mkdir python-module && cd python-module
git clone --depth 1 --no-checkout [email protected]:myorg/mymodules.git ./
git sparse-checkout init --no-cone
git sparse-checkout set python-module/
git checkout main

Using Older Version of Git

mkdir python-module && cd python-module
git clone --depth 1 --no-checkout [email protected]:myorg/mymodules.git ./
git config core.sparsecheckout true
echo 'python-module/' >> .git/info/sparse-checkout
git checkout main

My directory structure would now look like this:

  ../python-module/
    .git/
    python-module/
      __init__.py
      module.py

There are a variety of other options obviously and ways to check out root files (--cone vs. --no-cone) , but this is the gist of it

@jplindquist jplindquist linked a pull request May 2, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants