Skip to content

Fetching all refs and tags on every push can be really slow for large repositories #5848

@pastelsky

Description

@pastelsky

Describe the bug
At the moment, doing a git push on a repository with git lfs enabled executes git lfs pre-push. One of the commands executed as a part of git pre-push seems to be — 

trace git-lfs: exec: git '-c' 'filter.lfs.smudge=' '-c' 'filter.lfs.clean=' '-c' 'filter.lfs.process=' '-c' 'filter.lfs.required=false' 'ls-remote' '--heads' '--tags' '-q' 'origin'

In a very large repository, which has CI systems tagging releases every hour and a large number of refs, this currently takes ~10s to execute slowing down git push for everyone.

Expected behavior
--tags are omitted or there is some sort of caching that avoids making a call to fetch all remotes on all pushes. Tags can be an ever-growing list and most git commands do not fetch tags by default (or it is possible to set fetching of tags off by default easily).

Output of git lfs env

git-lfs/3.5.1 (GitHub; darwin amd64; go 1.22.1)
git version 2.46.0

LocalReferenceDirs=
ConcurrentTransfers=8
TusTransfers=false
BasicTransfersOnly=false
SkipDownloadErrors=false
FetchRecentAlways=false
FetchRecentRefsDays=7
FetchRecentCommitsDays=0
FetchRecentRefsIncludeRemotes=true
PruneOffsetDays=3
PruneVerifyRemoteAlways=false
PruneVerifyUnreachableAlways=false
PruneRemoteName=origin
AccessDownload=basic
AccessUpload=basic
DownloadTransfers=basic,lfs-standalone-file,ssh
UploadTransfers=basic,lfs-standalone-file,ssh
GIT_EXEC_PATH=/usr/local/opt/git/libexec/git-core
GIT_TRACE2_PARENT_NAME=_run_dashed_
GIT_TRACE2_PARENT_SID=20240827T034806.415503Z-H0456b86c-P0000772d
git config filter.lfs.process = "git-lfs filter-process --skip"
git config filter.lfs.smudge = "git-lfs smudge --skip -- %f"
git config filter.lfs.clean = "git-lfs clean -- %f"

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpatches-welcomeThe core team will accept patches for this feature, but is not planning to implement it themselves.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions