How do I rename a GitHub repository via their API?

This is possible through the Edit Repository GitHub API method, but here's the simplest example to do this with curl:

curl \
 -H "Authorization: Token [token]" \
 -H "Content-Type:application/json" \
 -H "Accept: application/json" \
 -X PATCH \
 --data '{ "name": "new-repo-name" }' \
 https://api.github.com/repos/owner/old-repo-name

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

Tags:

Git

Github Api