Close Menu
Rob FaulsRob Fauls
    What's Hot

    Odoo 17- Change default email address

    March 10, 2024

    Odoo 17- Automated Install on Debian 12

    December 26, 2023

    Odoo 17- Manual Install on Debian 10/Debian 11/Debian 12

    November 8, 2023
    Facebook X (Twitter) LinkedIn
    • Home
    • VMware
      • Storage
    • Odoo
    • Linux
    • About
      • About Me
      • Privacy Policy
    Rob FaulsRob Fauls
    Home » Migrate from Github to Gitea
    Linux

    Migrate from Github to Gitea

    Rob FaulsBy Rob FaulsSeptember 21, 2023Updated:September 26, 20237 Comments
    Facebook Twitter LinkedIn Email Reddit Telegram
    Share
    Facebook Twitter LinkedIn Pinterest Email

    What?

    The below script will help automate the process of migrating all public projects from a GitHub user to a Gitea Organization. Before running the script, please be sure to create the organization in Gitea and create a token specifically for this script.

    Why?

    A number of folks have reacted negatively to GitHub’s introduction of Copilot. It’s got great possibilities for those that are primarily concerned with getting their projects out without spending all their time on the code itself. It also poses massive concerns about intellectual property theft. While I am certainly not the most adept coder, I do value privacy and giving credit where credit is due, and have largely left GitHub as a result of Copilot.

    How?

    This script follows the workflow below:

    1. Identify the UID for the gitea user  and verify that UID works (required for the API).
    2. Identify the current GitHub rate limit and remaining allowed calls to GitHub’s API.
    3. Perform the migration
      • Check the state file for progress. This will help if the operation is broken at some point and needs to be resumed (resume is untested)
      • Gather list of the repositories and handle pagination if the user has more than 100 repos.
      • Check if the repo already exists in Gitea and skip if it does.

    Before running the script, you will need to specify the following values in the “User-input variables” section:

    USERNAME=”YOUR_GITHUB_USERNAME” # Replace with the GitHub user’s username
    GITEA_USER=”YOUR_GITEA_USER”  # This is the Gitea user who initiates the migration
    GITEA_TOKEN=”YOUR_GITEA_TOKEN” # Replace with your Gitea token
    GITEA_URL=”https://code.flatironnetworks.com” #Replace with your Gitea URL
    REPO_OWNER=”YOUR_GITEA_ORGANIZATION”  # Gitea organization under which the repos will be placed
    STATE_FILE=”migration_state.txt”

     

    ASSUMPTION #1: This script assumes you will be using an organization to post all new repositories into. Let’s face it some folks have a ridiculous number of repos and this function will greatly assist in organizing your environment. I’ve not tested using the script without “REPO_OWNER” specified or any error handling that may result from the removal of this function.

    ASSUMPTION #2: If you want the repositories to not be listed publicly, then you will need to set the Organization’s visibility to either “Private” or “Limited”. If you leave the organization “Public”, then all repos within the org will be publicly browsable. You can also edit the script “private” setting to “true” (contained in Assumption #3 screenshot below), but setting organization privacy is the recommended method.

    ASSUMPTION #3: You want the local repository to be updated with any changes in the GitHub project. Most of the time, you’ll want this to ensure you’re staying up to date with the main project’s code…but you might not want it. If you don’t, please change “true” to “false” in the line that reads ‘“mirror”: true,‘

     

    The Code!

    As this code will likely change over time, I’ve placed it onto my Git server.

    Featured git gitea github migrate
    Previous ArticleEdit hosts file in Windows and Linux
    Next Article What’s with the photos?

    Related Posts

    Odoo 17- Automated Install on Debian 12

    December 26, 2023

    Odoo 17- Manual Install on Debian 10/Debian 11/Debian 12

    November 8, 2023

    Upgrade Debian 11 to Debian 12

    August 17, 2023

    Benchmark persistent disk performance on Linux

    August 17, 2023

    7 Comments

    1. John Crisp on February 23, 2024 2:42 pm

      Your script/website seems to have disappeared! That was quick 🙂

      Any idea where I can get a copy?

      Thnaks.

      Reply
      • Rob Fauls on February 23, 2024 2:57 pm

        You caught me. I started to do a migration earlier this week and it stalled out. Give me a few minutes and I’ll get the server back online!

        Reply
      • Rob Fauls on February 23, 2024 3:17 pm

        Hokay, code is back online. Sorry to leave you hanging!

        Reply
        • John Crisp on February 25, 2024 12:18 pm

          Hahaha – sounds like me 🙂

          Many thanks!!

          B. Rgds
          John

          Reply
        • John Crisp on February 25, 2024 12:38 pm

          FYI there is a little inconsistency with variables between your notes here and your gitea repo and the script.

          It reads the config file for GITHUB_USERNAME but then uses this:

          “https://api.github.com/users/$USERNAME/repos”)

          It also uses $GITEA_USER and checks they exist but then uses:

          curl….
          “uid”: ‘$USER_ID’,

          Which I think should be $GITEA_USER

          We also have $REPO_OWNER but that doesn’t get read as a $VAR 🙂

          And then $GITEA_ORG is a floater by itself.

          I’d do a patch but can’t do a PR 🙂

          Reply
    2. Rob Fauls on February 25, 2024 4:49 pm

      aight John…let’s get you that login! This was part of a project over the course of a couple of days and I did not do much (apparently any) QC on the code. You’re gonna get an email from me shortly. Thanks for offering to help improve things. <3

      EDIT: I'm running around a bit today, so won't be able to dig into things until at least Monday, but let's see how we can make this tool more useful for everyone. If you've got LinkedIn, holler at me on there so I can spy on you...I mean...get to know you better!

      Reply
      • John Crisp on February 26, 2024 10:34 am

        Hi Rob,

        Got that thanks 😉 NP – I understand.

        Happy to help – I am no great coder but not a complete noob. I’ll open an issue with my notes from here and we can work on it thereafter.

        Found you on LinkedIn – I rarely visit the spawn of the devil!!

        Reply
    Leave A Reply Cancel Reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    Editors Picks
    Latest Posts

    Odoo 17- Change default email address

    March 10, 2024

    Odoo 17- Automated Install on Debian 12

    December 26, 2023

    Odoo 17- Manual Install on Debian 10/Debian 11/Debian 12

    November 8, 2023

    Subscribe to Updates

    Get the latest content from Rob.

    I've worked in IT for over 20 years, servicing Government, Healthcare, and Private Sector customers. This is a relatively new adventure into blogging, mostly out of a realization that I need to organize some of my notes on various subjects. Hopefully the articles posted will help others along the way.

    You can connect with me here:

    LinkedIn X (Twitter) Facebook

    Subscribe to Updates

    Keep up to date with new articles posted about 'stuff and things'.

    © 2025 Rob Fauls. Hosted by Flatiron Networks.
    • Home

    Type above and press Enter to search. Press Esc to cancel.