Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I rename a GitHub repository via their API?

Tags:

git

github-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?

like image 593
Ryan C. Thompson Avatar asked Jan 24 '11 00:01

Ryan C. Thompson


2 Answers

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
like image 165
braitsch Avatar answered Oct 24 '22 02:10

braitsch


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
like image 43
Brendan Forster Avatar answered Oct 24 '22 03:10

Brendan Forster