I am trying to setup Github Workflow for a Hugging Face space.
But I receive following error message:
remote: -------------------------------------------------------------------------
remote: Your push was rejected because it contains binary files.
remote: Please use https://git-lfs.github.com/ to store binary files.
remote: See also: https://hf.co/docs/hub/adding-a-model#uploading-your-files
remote: -------------------------------------------------------------------------
remote: Offending files:
remote: - ballon.jpg (ref: refs/heads/main)
remote: - fountain.jpg (ref: refs/heads/main)
remote: - wolf.jpg (ref: refs/heads/main)
To https://huggingface.co/spaces/satpalsr/RegNet-Image-Classification
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://huggingface.co/spaces/satpalsr/RegNet-Image-Classification'
Error: Process completed with exit code 1.
Modified Code I tried:
name: Sync to Hugging Face hub
on:
push:
branches: [main]
# to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
sync-to-hub:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
lfs: true
- name: Checkout LFS objects
run: git lfs checkout
- name: Push to hub
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: git push --force https://satpalsr:$HF_TOKEN@huggingface.co/spaces/satpalsr/RegNet-Image-Classification main
Hey there! As per the error message, the binary files should be tracked with git lfs.
What you can do is
# Track the files being rejected
git lfs track "your_file" # or *.your_extension
# Track things
git lfs install
Note that if you have commits with those files, it will still be rejected since the binary files are in previous commits without git lfs, so you will need to change that.
I face the same issue as well, I had previous commits to binary files without lfs commits but later on, I enabled git lfs but still my workflow fails since the file is there in the previous commits. How do I fix this?
hi @joselobenitezg ,
You probably have the offending files committed to the git history without LFS, it’s a common issue. Please reset your commit history, removing the commits with files without LFS tracking.
After I undid my last commit and followed your instructions, I was able to add the new staged changes to the staging area, committing, and then pushing without a problem. Thank you.
Decided to make a new space, then clone it, edit .gitattributes (already provided by HF) to add the file-format there.
*.sqlite3 filter=lfs diff=lfs merge=lfs -text
Running git lfs track "*.sqlite3" confirmed that it was already tracked with lfs there.
Then push.
Then add all my stuff for the project from a different folder - push - works.