rts-commander / docs /GIT_CONFIG_HF_SPACES.md
Luigi's picture
chore(structure): move docs into docs/ and tests into tests/
ccbaf39
|
raw
history blame
4.37 kB

๐Ÿ”ง Git Configuration - HF Spaces as Default Remote

Date: 3 octobre 2025
Status: โœ… Configured


๐Ÿ“Š Current Configuration

Remote Setup

space   https://huggingface.co/spaces/Luigi/rts-commander (fetch)
space   https://huggingface.co/spaces/Luigi/rts-commander (push)

Branch Tracking

* master [space/main] - Tracks HF Spaces main branch

Push Configuration

push.default = upstream

โœ… What This Means

Simple Workflow Now Available

Before:

git push space master:main --force

Now:

git push

That's it! ๐ŸŽ‰


๐Ÿš€ New Deployment Workflow

1. Make Changes

cd /home/luigi/rts/web

# Edit your files
vim app.py
vim static/game.js
# etc.

2. Commit Changes

git add .
git commit -m "feat: Add new feature"

3. Push to HF Spaces

git push

Done! Your changes are now on Hugging Face Spaces and will trigger a rebuild.


๐Ÿ” How It Works

Branch Tracking

Your local master branch now tracks space/main:

  • git status shows if you're ahead/behind HF Spaces
  • git pull fetches from HF Spaces
  • git push pushes to HF Spaces

Push Strategy

With push.default = upstream:

  • Git automatically pushes to the tracked upstream branch
  • No need to specify remote or branch names
  • master โ†’ space/main mapping is automatic

๐Ÿ“ Configuration Commands Used

# Set upstream tracking
git branch --set-upstream-to=space/main master

# Configure push default
git config push.default upstream

# Verify configuration
git branch -vv
git status

๐Ÿ”„ Full Example Workflow

# Navigate to project
cd /home/luigi/rts/web

# Check status
git status
# Output: "Votre branche est ร  jour avec 'space/main'"

# Make changes
echo "console.log('New feature');" >> static/game.js

# Stage changes
git add static/game.js

# Commit
git commit -m "feat: Add logging"

# Push to HF Spaces (automatic!)
git push

# HF Spaces will automatically rebuild

๐ŸŽฏ Benefits

Before Configuration

  • โŒ Long command: git push space master:main --force
  • โŒ Easy to forget branch mapping
  • โŒ Risk of pushing to wrong branch
  • โŒ Verbose and error-prone

After Configuration

  • โœ… Simple command: git push
  • โœ… Automatic branch mapping
  • โœ… Git tracks upstream status
  • โœ… Clean and intuitive

๐Ÿ”ง Advanced Commands

Check Current Tracking

git branch -vv
# Output: * master 1b4f6c0 [space/main] docs: Add...

Check Configuration

git config --get push.default
# Output: upstream

git config --get branch.master.remote
# Output: space

git config --get branch.master.merge
# Output: refs/heads/main

Pull Changes from HF Spaces

git pull
# Equivalent to: git pull space main

Push Changes to HF Spaces

git push
# Equivalent to: git push space master:main

๐Ÿ› Troubleshooting

If Push Fails

Check tracking:

git branch -vv

Re-configure if needed:

git branch --set-upstream-to=space/main master

If Pull Fails

Fetch first:

git fetch space
git branch -vv

Force pull if diverged:

git pull --rebase

If You Need to Push Elsewhere

Override with explicit remote:

git push origin master  # Push to different remote
git push space main     # Push to different branch

๐Ÿ“Š Status Interpretation

"Votre branche est ร  jour avec 'space/main'"

โœ… Everything synced, ready to push new changes

"Votre branche est en avance sur 'space/main' de 1 commit"

๐Ÿ”ผ You have local commits to push: git push

"Votre branche est en retard sur 'space/main' de 1 commit"

๐Ÿ”ฝ HF Spaces has changes you don't have: git pull

"Votre branche et 'space/main' ont divergรฉ"

โš ๏ธ Both have different commits: git pull --rebase then git push


๐Ÿ”— Related Documentation

  • web/docs/DEPLOYMENT_HF_SPACES.md - Complete deployment guide
  • web/DEPLOY_QUICK.md - Quick reference
  • HF_SPACES_DEPLOYED.md - Deployment summary

โœ… Configuration Complete!

You can now use git push to deploy directly to Hugging Face Spaces! ๐Ÿš€

Space URL: https://huggingface.co/spaces/Luigi/rts-commander
App URL: https://Luigi-rts-commander.hf.space