Conversation
Repositories with a very large number of branches, tags, and other refs
(e.g. hundreds of branches/tags and hundreds of thousands of commits) can
make Updatecli's git scm checkout very slow, even when a shallow `depth`
is configured. There are two contributing factors in
`pkg/plugins/utils/gitgeneric` (GoGit, shared by the github, gitlab,
gitea, bitbucket, stash, azuredevops and git scms):
- The initial `git.PlainClone` fetches every branch on the remote by
default (go-git's default clone refspec is
`+refs/heads/*:refs/remotes/<remote>/*`), regardless of `depth`.
- Right after cloning, an unconditional fetch is issued with
`RefSpecs: []config.RefSpec{"refs/*:refs/*"}`, which mirrors every ref
on the remote (branches, tags, pull request refs, notes, etc.) on every
single Updatecli execution.
This change adds a new opt-in `singleBranch` spec field. When enabled:
- the clone only fetches the configured branch
(`SingleBranch`+`ReferenceName` on `git.CloneOptions`), and
- the post-clone `refs/*:refs/*` reconciliation fetch is skipped
entirely.
Default behavior (flag unset) is unchanged. As a documented trade-off,
enabling `singleBranch` skips the full ref reconciliation, which in some
edge cases can make Updatecli miss an already published working branch
and create a duplicate pull request.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
olblak
previously approved these changes
Jul 15, 2026
olblak
left a comment
Member
There was a problem hiding this comment.
Thank you for the great pull request, covering all scm provider plus the documentation.
I assume you tested it so I am happy to merge as is
Contributor
Author
|
I made a test with the repository that hit the issue, we moved from 19 minutes to process the pipeline to 43 seconds |
|
Tick the box to add this pull request to the merge queue (same as
|
The typos CI check fails on main (e.g. PR updatecli#9565) due to a pre-existing spelling typo unrelated to the singleBranch scm change. Fixing it here so this PR's CI can pass cleanly. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kuisathaverat
commented
Jul 15, 2026
kuisathaverat
commented
Jul 15, 2026
This reverts commit 6183807.
Contributor
Author
|
There are some issues with the Check Spell, but they are in files that I did not touch, so I will not fix them. As a reference, this is the fix 6183807. I will revert now. |
Member
|
It now complains because of this pullrequest that I merged this morning https://github.com/updatecli/updatecli/pull/9565/checks I can fix it in a different pr |
olblak
approved these changes
Jul 15, 2026
olblak
added a commit
to updatecli/website
that referenced
this pull request
Aug 6, 2026
Adds a new 'Performance on large repositories' subsection to each scm plugin doc (github, gitlab, gitea, bitbucket, stash, azuredevops, git) explaining the new singleBranch option (paired with depth) that lets Updatecli skip fetching every branch, tag, and ref on the remote, along with a runnable example for each plugin. Related to updatecli/updatecli#9590. Co-authored-by: kuisathaverat <kuisathaverat@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: Olblak <me@olblak.com> Co-authored-by: Olivier Vernin <olivier@vernin.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Updatecli pipelines targeting repositories with a very large number of branches, tags, and other refs (hundreds of branches/tags, 350k+ commits) can spend a very long time (measured up to ~19 minutes) just checking out the git scm, even when
depthis set to a low value.Two issues were found in the shared native git implementation used by every git-based scm (
github,gitlab,gitea,bitbucket,stash,azuredevops,git) —pkg/plugins/utils/gitgeneric(GoGit, built ongo-git):git.CloneOptionsis built withoutSingleBranch/ReferenceName, so go-git falls back to its default refspec+refs/heads/*:refs/remotes/<remote>/*(all branches) —depthonly limits the commit history per ref, not the number of refs fetched.RefSpecs: []config.RefSpec{"refs/*:refs/*"}. This matches every ref namespace on the remote — not just branches and tags, but alsorefs/pull/*,refs/notes/*, and any other custom ref — on every single Updatecli execution, whether the local clone was fresh or reused.For a repository with hundreds of branches/tags and a long history, this second point in particular is extremely expensive and explains slow checkouts even with
depthconfigured.Solution
This PR adds a new opt-in
singleBranchoption to every git-based scm's spec (github,gitlab,gitea,bitbucket,stash,azuredevops,git), following the same pattern as the existingsubmodules/depthoptions.When
singleBranch: trueis set:branch(SingleBranch: true+ReferenceNameongit.CloneOptions), instead of every branch on the remote.refs/*:refs/*reconciliation fetch is skipped entirely.When the option is left unset (default), behavior is 100% unchanged — this is purely opt-in.
Trade-off
Skipping the full ref reconciliation fetch means Updatecli may, in some edge cases, fail to detect an already-published working branch and create a duplicate pull request. This is documented on the new option and is an acceptable trade-off compared to multi-minute checkouts on very large repositories.
Example
Impact
Measured on a repository with hundreds of branches/tags and ~350k commits, enabling
singleBranchreduced the scm checkout time from ~19 minutes to ~43 seconds.Validation
go build ./...go vet ./pkg/plugins/scms/... ./pkg/plugins/utils/gitgeneric/...go test ./pkg/plugins/scms/... ./pkg/plugins/utils/gitgeneric/...— all pass (one pre-existing, unrelated failure inTestGoGit_RemoteURLsconfirmed present onmainas well, due to the local worktree environment)