# Hugging Face Deployment Fix Guide ## Problem The push to Hugging Face was rejected because the remote repository contains changes that aren't in your local repository. ## Quick Solution ### Option 1: Use the PowerShell Script (Recommended) Run the new PowerShell script that handles everything automatically: ```powershell cd C:\Users\Dell\Desktop\TimeTravel-main\sci-image # Set your token first $env:HF_TOKEN = "hf_YOUR_ACTUAL_TOKEN_HERE" # Run the script .\deploy-to-huggingface.ps1 ``` This script will: - Add and commit your changes - Set up the HF remote with authentication - Pull and merge remote changes - Push to Hugging Face with proper error handling ### Option 2: Manual Steps If you prefer to do it manually: ```powershell cd C:\Users\Dell\Desktop\TimeTravel-main\sci-image # 1. Set your token (replace with actual token) $env:HF_TOKEN = "hf_YOUR_ACTUAL_TOKEN_HERE" # 2. Add and commit your changes git add -A git commit -m "Update sci-image deployment" # 3. Set up HF remote with token git remote add hf https://$env:HF_TOKEN@huggingface.co/spaces/gsstec/sci-image # 4. Pull remote changes (merge strategy) git pull hf main --allow-unrelated-histories --no-rebase -X theirs # 5. Push to Hugging Face git push hf main ``` ### Option 3: Force Push (Use with Caution) If you're certain your local version is correct and want to overwrite the remote: ```powershell cd C:\Users\Dell\Desktop\TimeTravel-main\sci-image # Set your token $env:HF_TOKEN = "hf_YOUR_ACTUAL_TOKEN_HERE" # Add remote if not exists git remote add hf https://$env:HF_TOKEN@huggingface.co/spaces/gsstec/sci-image # Force push git push hf main --force ``` ⚠️ **Warning**: Force push will overwrite any changes on the remote repository. ## What Caused This Issue? The error occurred because: 1. The Hugging Face Space repository has commits that aren't in your local repository 2. Git prevents pushing to avoid losing those remote changes 3. You need to pull and merge those changes before pushing ## Files Modified The deployment scripts have been updated: - `deploy-to-huggingface.bat` - Updated with pull/rebase logic - `deploy-to-huggingface.ps1` - New PowerShell script with comprehensive error handling ## Next Steps 1. Set your HF_TOKEN environment variable with your actual token 2. Run the PowerShell script: `.\deploy-to-huggingface.ps1` 3. The script will handle the merge automatically 4. Your changes will be pushed to: https://huggingface.co/spaces/gsstec/sci-image ## Troubleshooting ### If you get merge conflicts: ```powershell # Accept your local changes git checkout --ours . git add -A git rebase --continue # Or accept remote changes git checkout --theirs . git add -A git rebase --continue ``` ### If the remote URL is wrong: ```powershell $env:HF_TOKEN = "hf_YOUR_ACTUAL_TOKEN_HERE" git remote set-url hf https://$env:HF_TOKEN@huggingface.co/spaces/gsstec/sci-image ``` ### To check current remotes: ```powershell git remote -v ``` ## Space URL Your Hugging Face Space: https://huggingface.co/spaces/gsstec/sci-image ## Important Security Note Never commit files with actual tokens. Always use environment variables or .env files (which are in .gitignore).