jesseduffield / jesseduffield/lazygit
clone tips: partial, shallow, sparse
- Dominant language
- Go
- Stars
- 82.4k
- Forks
- 3k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 19
Description
> [!note]
> disclaimer: I've only searched the codebase, I haven't actually used this software (yet)
I assume there's no feature for doing a [partial or shallow `clone`](https://github.blog/open-source/git/get-up-to-speed-with-partial-clone-and-shallow-clone), but if such feature were to be added, I have tips to share:
- If the user has a shallow clone, **warn them before amending the grafted commit**. [Amending such commits will break the history](https://github.com/helix-editor/helix/pull/13944#issuecomment-3069190843)
- If the user wants to do a shallow-clone, it's likely they also want to apply a `--filter` to it. Git allows clones to be *shallow and partial at the same time*. I have some experience with such repos, everything is fine so far!
- Before computing the `blame` of a file in a blobless-clone, use [`backfill`](https://git-scm.com/docs/git-backfill) to fetch faster (typically, this is not necessary for shallow+partial). I guess Git doesn't do this by default because `backfill` is experimental (according to the manpage)
- When rebasing 2 branches in a partial-clone, [use `--reapply-cherry-picks`](https://news.ycombinator.com/item?id=43397816) to avoid potential ["infinite" loops](https://github.com/cli/cli/discussions/11759) when the branches differ too much
- If the user wants a `--sparse` checkout at `clone`-time, it's 99% likely they also want to apply a filter **and** run `git config set merge.stat false`. This ensures that `git pull` (which has `--stat` by default) doesn't `fetch` extra blobs to compute the summarized `diff`. Disabled `stat` is useless for non-`sparse`, because git will compute the diff anyways.
[More info here](https://github.com/StevenBlack/hosts/issues/3005#issuecomment-3531659871)
Contributor guide
Assessment
This issue has not been assessed yet.