Bulk migrate issues with the GitHub CLI

| 1 minute read

I recently had to move a whole lot of GitHub issues between two repos before disabling them on the source repo. The GitHub UI lets you migrate single issues but that would take hours since some of the repos had over a hundred issues.

Thankfully the GitHub CLI lets you transfer issues pragmatically like so:

gh issue transfer <issue ID> <destination repo>

So a few shell pipes later and we have this:

gh issue list -s all -L 500 --json number | \
    jq -r '.[] | .number' | \
    xargs -I% gh issue transfer % https://github.com/<destination repo>

The first command gets the last 500 issues from the source repo (Assuming you’re in the correct directory for the repo) and prints out the issue number in JSON. jq then prints all the numbers in plain text (I could probably do this without jq via the CLI, but this was easy enough). Finally xargs grabs all the issues and runs them through the GitHub CLI again to transfer it to our destination repo.

Run multiple times if you have to transfer more than 500 issues or increase the value!