Skip to content

Git LFS prune deletes staged objects #5636

@jochenhz

Description

@jochenhz

Describe the bug
Staged LFS files are deleted by git lfs prune. If I create a commit after that, the commit is broken and cannot be pushed. Even worse, if I have multiple local commits, I have permanently lost data. Note, --verify-remote does not prevent this

To Reproduce
Steps to reproduce the behavior:
git init
git lfs install
git lfs track myfile.data
git add .
git lfs prune

Verify that the LFS objects have been deleted from .git/lfs/objects

Expected behavior
Staged files should be retained in the same way as stashed or reachable files.
--verify-remote should check every file that is deleted, I guess?

System environment
macOS 13.4

Output of git lfs env

git-lfs/3.4.0 (GitHub; darwin arm64; go 1.20.6)
git version 2.42.0

Endpoint=https://github.com/jochenhz/lfs-bug.git/info/lfs (auth=basic)
LocalWorkingDir=/Users/jochenhunz/Downloads/gitlfs-bug/lfs-bug
LocalGitDir=/Users/jochenhunz/Downloads/gitlfs-bug/lfs-bug/.git
LocalGitStorageDir=/Users/jochenhunz/Downloads/gitlfs-bug/lfs-bug/.git
LocalMediaDir=/Users/jochenhunz/Downloads/gitlfs-bug/lfs-bug/.git/lfs/objects
LocalReferenceDirs=
TempDir=/Users/jochenhunz/Downloads/gitlfs-bug/lfs-bug/.git/lfs/tmp
ConcurrentTransfers=8
TusTransfers=false
BasicTransfersOnly=false
SkipDownloadErrors=false
FetchRecentAlways=false
FetchRecentRefsDays=7
FetchRecentCommitsDays=0
FetchRecentRefsIncludeRemotes=true
PruneOffsetDays=3
PruneVerifyRemoteAlways=false
PruneRemoteName=origin
LfsStorageDir=/Users/jochenhunz/Downloads/gitlfs-bug/lfs-bug/.git/lfs
AccessDownload=basic
AccessUpload=basic
DownloadTransfers=basic,lfs-standalone-file,ssh
UploadTransfers=basic,lfs-standalone-file,ssh
GIT_EXEC_PATH=/opt/homebrew/opt/git/libexec/git-core
git config filter.lfs.process = "git-lfs filter-process"
git config filter.lfs.smudge = "git-lfs smudge -- %f"
git config filter.lfs.clean = "git-lfs clean -- %f"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions