--- title: Hugging Face To Github Transfer emoji: 🧪 colorFrom: red colorTo: gray sdk: gradio sdk_version: 5.35.0 app_file: app.py pinned: false license: unlicense short_description: Repo Transfer --- # Hugging Face to GitHub Transfer This tool allows you to transfer a Hugging Face model repository to a new GitHub repository with ease, using a simple web interface built with Gradio. It automates cloning the Hugging Face repo, creating a GitHub repo, and pushing the code, while handling authentication securely via a `token.env` file. --- ## Features - Clone any Hugging Face repository via its `.git` URL. - Create a new GitHub repository (public or private). - Push the cloned repo to GitHub under your account. - Supports specifying GitHub branch and repo visibility. - Upload or generate a `token.env` file for secure token management. - Validates GitHub token scopes and provides detailed error messages. - Simple web UI with Gradio for easy use. --- ## Getting Started ### Requirements - Python 3.7+ - Git installed and accessible from your command line - A GitHub Personal Access Token (classic token) with the `repo` scope enabled. ### GitHub Token Setup 1. Go to https://github.com/settings/tokens. 2. Generate a classic token with the following permissions: - repo (full control of private repositories) 3. Copy the generated token (starts with `ghp_` and is 40 characters long). 4. Optionally, create a file named `token.env` with the following content: GITHUB_TOKEN=your_github_token GITHUB_USERNAME=your_github_username GIT_USER_NAME=Your Name GIT_USER_EMAIL=you@example.com REPO_VISIBILITY=public GIT_BRANCH=main --- ## Running the Tool Simply run the script. It will launch a local Gradio web app. python your_script_name.py --- ## Using the Interface - You can upload your `token.env` file to autofill your credentials and settings, or manually input them. - Provide the Hugging Face repo URL (e.g., https://huggingface.co/username/model.git). - Enter a name for the new GitHub repo. - Fill in or verify GitHub username, token, commit author name/email. - Select the branch and visibility for the new GitHub repo. - Click Start Transfer to begin the process. - After completion, download the generated `token.env` file for future use. --- ## Example token.env GITHUB_TOKEN=ghp_yourtokenhere1234567890abcdef12345678 GITHUB_USERNAME=yourgithubusername GIT_USER_NAME=Your Name GIT_USER_EMAIL=youremail@example.com REPO_VISIBILITY=public GIT_BRANCH=main --- ## Troubleshooting - Token validation fails: Ensure your token is valid, has repo scope, and is not expired. - Rate limit exceeded: Wait for the reset time or use a token with higher limits. - Branch not found on remote: The branch you selected may not exist yet; you can still push to create it. - Git not installed: Install Git and make sure it’s in your system PATH. - Repo already exists: The tool will continue and push changes to the existing repo. --- ## Security Notes - Your GitHub token is only stored locally in the `token.env` file you upload or download. - Never share your token with others. - Use tokens with the least privileges needed, and set expiration if desired. --- ## License This script is open-source and free to use. --- ## Contact For questions or issues, please open an issue or contact the maintainer. --- Enjoy seamless transfer from Hugging Face to GitHub! Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference