Search code examples
gitgithub-api

How do I rename a GitHub repository via their API?


Looking at the GitHub API reference at http://develop.github.com/p/repo.html, I see all sorts of good stuff, but I don't see any way to rename a repository through the API. Is there any way to do so?


Solution

  • Create some variables for clarity:

    user=MyUserName
    pass=MyPassword
    newName='{"name": "NewNameForRepo"}'
    oldName="MyRepo"
    

    Then use curl to make the request:

    curl -u "$user:$pass" -X PATCH -d "$newName" https://api.github.com/repos/$user/$oldName