question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: Option to shallow clone but still fetch tags

See original GitHub issue

We use the Python package setuptools-git-version for a variety of Python package automation steps and it runs git describe --tags --long --dirty in order to compare the HEAD commit with the most recent tag.

With checkout@v2’s default to shallow clones (a default that I agree is sensible), this no longer works, and we have to set fetch-depth: 0. This works just fine, but it would be nice if there were an option to do a shallow clone of the HEAD commit and also fetch tags.

Thanks for considering.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:29
  • Comments:7

github_iconTop GitHub Comments

9reactions
devinrsmithcommented, Jan 23, 2021

I’m looking for this feature as well (the ability to git-describe the checkout), but I don’t think this can be done in a shallow manner. That said, you don’t need unrelated history; only the history related to the desired commit. Right now I’m using fetch-depth: 0 as a workaround, but that is a heavy hammer that is pulling in more than necessary.

The default checkout seems to do:

git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +<sha>:<ref>

and I think by omitting --no-tags and --depth=1, it achieves the desired goals. (Note, that specifying --tags is not the same as omitting --no-tags.) Ie:

git -c protocol.version=2 fetch --prune --progress --no-recurse-submodules origin +<sha>:<ref>

It would be nice if there was an easy way to configure this type of checkout.

2reactions
dlechcommented, Nov 23, 2020

Setting fetch-depth: 0 seems as simple as it gets.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get up to speed with partial clone and shallow clone
Git's partial clone and shallow clone features are options that can help here, but they come with their own tradeoffs. Each option breaks...
Read more >
Need to omit `--tags` when performing shallow clone.
I am trying to speed up the checkout step when building a large repository. I have enabled shallow clones by setting fetch depth....
Read more >
Project Setting "Git shallow clone" and "GIT_DEPTH ... - GitLab
Per the documentation, a "Git shallow clone" value >0 and <=1000 should perform a shallow clone and fetch refs up to the value...
Read more >
How to Use Git Shallow Clone to Improve Performance
Your teams can still clone, push, and pull code using Git. They won't even know the difference! But unlike with native Git, developers...
Read more >
Can I make Git fetch a repository tag list without actually ...
If fetching to a shallow repository created by git clone with --depth= option (see git- clone(1)), deepen or shorten the history to the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found