[Spaces, Dev mode] VS Code web - cannot push commits

I haven’t used Dev mode from VSCode, so I’m not sure if the following applies, but I’ve seen similar cases.


You’re hitting Git auth and environment gaps inside Spaces Dev-Mode. VS Code Web runs inside the Space container, which has no Git credentials by default and may miss git-lfs. Hugging Face also removed password auth for Git in 2023, so username/password prompts always fail. Use a Hub token over HTTPS or SSH keys, and ensure git and git-lfs exist in the container. The original thread shows this exact pattern. (Hugging Face Forums)

Background

  • Dev-Mode starts a VS Code server and shell in the Space container, not your local machine. That context needs its own credentials and tools. The official Dev-Mode guide lists git and git-lfs as required. (Hugging Face)
  • Hugging Face disabled Git password auth on Oct 1, 2023. Only tokens or SSH are valid. Many users see the same prompt loop. (Hugging Face)

Root causes

  1. No Git credentials in the container. HTTPS push falls back to username/password and is rejected. (Hugging Face Forums)
  2. Missing or wrong token scope. A read-only token yields 403 on push. Use a write token. (Hugging Face)
  3. SSH not set up in the container. git@hf.co fails or prints “Hi anonymous.” Public key not added or wrong key selected. Sometimes stale known_hosts causes mis-match. (Hugging Face Forums)
  4. git-lfs absent or not initialized. Large files push fails or is refused. Dev-Mode requires git-lfs. (Hugging Face)
  5. Wrong remote or permissions. Pushing to the wrong repo URL or to a Space you cannot write. Multiple users report similar mis-routes. (Hugging Face Forums)
  6. Connection quirks with VS Code Remote. Recent reports show VS Code connection oddities around Dev-Mode. Auth must still be valid inside the container even if VS Code connects. (GitHub)

Fast fixes (choose HTTPS or SSH)

Option A — HTTPS with a Hub token

Run inside Dev-Mode terminal:

# Install CLI if missing; logs into Hub and stores token for Git
# Docs: https://huggingface.co/docs/huggingface_hub/en/guides/cli
pip install -U huggingface_hub  # https://pypi.org/project/huggingface_hub/
huggingface-cli login --add-to-git-credential  # https://huggingface.co/docs/huggingface_hub/en/quick-start

# Verify remote is the Space repo
git remote -v  # expect https://huggingface.co/spaces/<user>/<space>.git

# Commit and push
git add -A
git commit -m "Dev-Mode changes"
git push

Notes: Use a write-scoped token. Passwords do not work. (Hugging Face)

Option B — SSH key in the container

Run inside Dev-Mode terminal:

# Generate key and add public key to HF Settings → SSH keys
# Docs: https://huggingface.co/docs/hub/en/security-git-ssh
ssh-keygen -t ed25519 -N "" -f ~/.ssh/id_ed25519
cat ~/.ssh/id_ed25519.pub  # paste into HF account SSH keys

# Test and then switch remote to SSH
ssh -T git@hf.co  # should greet you by username
git remote set-url origin git@hf.co:spaces/<user>/<space>.git
git push

If ssh -T git@hf.co says “Hi anonymous,” you are not using the key HF knows. Ensure the correct key is loaded, and clear any stale known_hosts entry for hf.co before retrying. (Hugging Face Forums)

Make the container capable of pushing

# In Dev-Mode terminal
git --version || sudo apt-get update && sudo apt-get install -y git
git lfs version || sudo apt-get install -y git-lfs
git lfs install

For Docker Spaces, bake these into your Dockerfile:

# Docs: https://huggingface.co/docs/hub/en/spaces-dev-mode
RUN apt-get update && apt-get install -y git git-lfs bash curl wget procps

Track common large files before first push:

# Docs: https://git-lfs.com
git lfs track "*.pt" "*.safetensors" "*.bin" "*.onnx" "*.jpg" "*.png"
git add .gitattributes

Dev-Mode explicitly requires git and git-lfs. Without them, commits stay local and pushes fail. (Hugging Face)

Diagnostics checklist

  • git remote -v shows https://huggingface.co/spaces/<user>/<space>.git or git@hf.co:spaces/<user>/<space>.git. Fix if not. (Hugging Face)
  • HTTPS: huggingface-cli whoami returns your user. Token has write role. (Hugging Face)
  • SSH: ssh -T git@hf.co greets you by username. If not, re-add key or clean ~/.ssh/known_hosts. (Hugging Face Forums)
  • LFS: git lfs env and git lfs ls-files both work. Re-track binaries and re-commit if needed. (Hugging Face)

Similar cases you can map to

  • Beginners thread: “Error with authentication: git push.” Password deprecated. Use token or SSH. (Hugging Face Forums)
  • “Added my SSH key, cannot push.” “Hi anonymous” symptom and fix. (Hugging Face Forums)
  • Dev-Mode not working with VS Code reports. Confirms environment/auth pitfalls around Remote access. (Hugging Face Forums)

Keep it working

  • Store creds once: huggingface-cli login --add-to-git-credential in the container. Then git push is seamless. (Hugging Face)
  • Prefer SSH in shared or automated setups. Token rotation then isn’t needed on every container rebuild. (Hugging Face)
  • Track large files with LFS from day one to avoid rewrite headaches later. (Hugging Face)

Short, curated references

Set up and push

Auth pitfalls

Dev-Mode ecosystem

  • VS Code Remote issue tracking recent connection quirks. (GitHub)

Use Option A or B, verify tools, then push again from the Dev-Mode terminal.