如何通过 ssh 创建新存储库



我想利用 ssh 密钥提供的无密码访问机会创建新的存储库,而不是通过每次输入用户名和密码来打开浏览器并登录 git 托管提供商。如何通过 ssh 创建新的存储库?

GitHub API 确实为项目创建提供了一种机制,目前处于 alpha 状态。 见 https://developer.github.com/v3/projects/#create-a-repository-project

我使用这个/usr/local/bin/github

#!/bin/dash
# Create a personal access token here
#
#     https://github.com/settings/tokens
#
# and make sure it has the 'repo' scope.
TOKEN=`cat /home/user/github_token`
REPO=$2
curl -s -XPOST -H 'Authorization: token '$TOKEN https://api.github.com/user/repos -d '{"name":"'$REPO'"}'|egrep -w 'already|"name":'|grep -o '.*[^,]'|cut -d: -f2|perl -pe 's/^ "(.*)"/$1/;s/name already exists on this account/already exists/'|perl -pe "s/$REPO/successfully created/"

它以github init myrepo运行。从 CLI 创建和分叉项目很有用。

最新更新