Save Your HF Space on GitHub

Save Your HF Space on GitHub

The Simplest Method

  1. Go to https://git-lfs.com/ and download Git Large File Storage for your operating system.
    1. notion image
  1. In your Hugging Face space, open the menu with the three dots and select Clone repository.
    1. notion image
  1. Run the following commands in the terminal:
    1. First, run git lfs install to check that Git Large File Storage is installed. If installed, the response will be Git LFS initialized.
    2. Next, run git clone https://huggingface.co/spaces/<USERNAME>/<SPACE_NAME> and replace USERNAME and SPACE_NAME with your Hugging Face username and the name of the space you want to download. This command will download your space!
    3. notion image
  1. Create a new GitHub repository.
    1. notion image
  1. Complete the Repository name field and the Description, but do not add a README. Your project already has one! Click Create repository when you’re done.
    1. notion image
  1. There are many ways to set up a repository. Select the uploading an existing file option.
    1. notion image
  1. Drag and drop the files (not the folder) into your GitHub repository.
    1. notion image
  1. Tada! 🎉 Your Hugging Face project is now on GitHub! It’s probably a good idea to edit the README at this point to include a description of your project and a link to the Hugging Face space, so that readers can interact with your chatbot.

Other Methods

This method of creating a GitHub repository will not update with any new changes to your Hugging Face space. This is the simplest method, but there are others!

When the Simplest Method Makes Sense

  • You want to preserve a working version before major changes
  • You're migrating from HF Spaces to GitHub permanently
  • You want to share your HF Space code with collaborators who prefer GitHub
  • You need a backup before experimenting with your HF Space
  • You want to apply for jobs and showcase the code on GitHub
However, if you need to sync future changes in Hugging Face to your GitHub repository or you want changes in GitHub to sync with your Hugging Face space, you’ll need to configure GitHub Actions! Get started with learning about GitHub Actions here.