Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script deleted LFS files using git filter-repo but space is still used #2722

Open
m-elagdar opened this issue Dec 26, 2024 · 0 comments
Open

Comments

@m-elagdar
Copy link

Is your feature request related to a problem? Please describe.
I'm trying to save space by deleting lots of intermediate checkpoints using a script. But it seems like the files are deleted from git history but the CDN still has them and the repo still has the same size.

Describe the solution you'd like
There's an extra step I should add to the script but I'm not sure what is it.

Describe alternatives you've considered
The way that actually reduces the repo size is the menu in settings but it would take lots of effort to repeat the steps for each file.

Additional context
Here's the script

#!/usr/bin/env bash
# -*- coding: utf-8 -*-
set -eu -o pipefail
log() { echo "${@}" 1>&2; }; stt=$SECONDS; trap 'log $(basename $0): total duration: $(($SECONDS-$stt)) seconds' EXIT

# pip install git-filter-repo

repo_id=$1
pattern=$2
echo "Will clean '$pattern' from Repo ID: $repo_id"
read -p "Enter token: " -s hub_token
(! [ -z "$hub_token" ] || read -p "Enter token: " -s hub_token; GIT_LFS_SKIP_SMUDGE=1 git clone https://-:$hub_token@huggingface.co/$repo_id)
owd="$PWD"
repo_dir=$(basename $repo_id)
cd $repo_dir
git filter-repo --path-glob "$pattern" --invert-paths
(! [ -z "$hub_token" ] || read -p "Enter token: " -s hub_token; git remote add origin https://-:$hub_token@huggingface.co/$repo_id)
git push --set-upstream origin main -f
cd "$owd"
rm -rf "$repo_dir"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant