10

I learned how to add a repository via the command line with curl and how to add a description for a commit with git commit, but how to add a repository description via the command line?

Gerald Schade
  • 587
  • 5
  • 12
  • Do you mean using `git`? I don’t think you can, that’s a GitHub-specific thing. If you mean using GitHub’s API, check https://developer.github.com/v3/. – jonrsharpe Sep 24 '17 at 10:53

2 Answers2

10

As noted in this answer, a repo description as seen on the GitHub website is specific to GitHub only.

So .git/description would not work (only gitweb is using it)

Using the GitHub API would, but you need to integrate the verb PATH with your curl command in order to edit your repo.

curl \
  -X PATCH \
  -H "Accept: application/vnd.github+json" \ 
  -H "Authorization: token <TOKEN>" \
  --data '{"name":"repo", "description":"a new description"}' \
  https://api.github.com/repos/OWNER/REPO

Using GitHub CLI gh api:

gh api \
  --method PATCH \
  -H "Accept: application/vnd.github+json" \
  /repos/OWNER/REPO \
  -f name='Hello-World'
  -f description='This is your first repository'

Or gh repo edit:

gh repo edit OWNER/REPO -d "new Description"
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • when directy applying Your proposal, I got the error "Validation failed",..."field":"name" "message":"name is too short (minimum is 1 character)" ..., so by modifying Your --data -parameter to: '{"name":"repo", "description":"a new description"}', it worked! – Gerald Schade Nov 05 '18 at 23:35
  • @GeraldSchade Thank you. I have edited the answer accordingly. – VonC Nov 06 '18 at 05:50
  • What does `:owner/:repo` mean? Is it a placeholder to be changed by e.g. vonc/repo1 ? – Timo Apr 05 '22 at 21:19
  • 1
    @Timo A placeholder indeed. You need to replace `:owner` with a GitHub user account, and `:repo` with one of their repositories. – VonC Apr 05 '22 at 22:02
  • Is ist still `patch` or is it now in v3 `post` as `request`? – Timo Aug 16 '22 at 11:51
  • 1
    @Timo Still PATCH. I have updated the documentation link and example, as well as added the GitHub CLI `gh` commands. – VonC Aug 16 '22 at 12:04
2

Make sure your are in your project's root, where you can locate .git directory, you should do the following steps:

Modify the description file:

vi .git/description

Delete the existing text (press I to switch to edit/insert mode ):

Unnamed repository; edit this file 'description' to name the repository.

Replace the default text with your project's description

My Awesome Project

To save the file and close vi editor. press Esc -> X -> Enter

Zee
  • 1,865
  • 21
  • 42