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?
Asked
Active
Viewed 4,508 times
10
-
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 Answers
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
-
-
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
-
-
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
-
as VonC wrote, this really did not work (for me), even after "git add -u", "git commit" and "git push". – Gerald Schade Nov 05 '18 at 23:45