git - 如何从 ubuntu 终端在 github 帐户中推送新的本地存储库?

标签 git github

我正在尝试将一个新的本地“repo”推送到我的 GitHub 帐户,但该帐户不存在,命令如下:

git push https://github.com/username/gitinit

出现错误:

remote: Repository not found.
fatal: repository 'https://github.com/username/gitinit/' not found

我的问题是:

我们可以使用命令提示符 Ubuntu 创建一个存储库(GitHub 帐户中不存在)吗?
如果可以的话怎么办?

最佳答案

您需要使用GitHub API for Repository以便从您的 Ubuntu shell session 创建一个新的存储库。

POST /user/repos

即 ( from this tutorial ):

curl -u 'YOUR-USER-NAME' https://api.github.com/user/repos -d '{"name": "PUT-YOUR-REPO-NAME-HERE"}'

您可以添加不同的选项:

{
  "name": "Hello-World",
  "description": "This is your first repository",
  "homepage": "https://github.com",
  "private": false,
  "has_issues": true,
  "has_wiki": true,
  "has_downloads": true
}

然后:

git remote add origin https://github.com/username/gitinit.git
git push -u origin master

您可以在“Is it possible to create a remote repo on GitHub from the CLI without opening browser?”中找到更多信息/替代方案。

关于git - 如何从 ubuntu 终端在 github 帐户中推送新的本地存储库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37609043/

相关文章:

java - 如何使 eclipse neon 在包 View 中显示 git 分支?

php - 在应用程序的页脚中写入 git commit 版本信息

git - 如何保持两个 git repos 同步?

git - 使用通配符过滤 git 分支

c# - 在 github 上托管 VisualStudio 项目的指南

python - Azure函数使用ssh访问私有(private)github存储库

linux - 无法从 Jenkins 访问 git repo

git - 将 SSH key 添加到 GitHub 的问题

bash - 如何执行存储在 Github 中的 SQL 文件?

r - 从 GitHub 导入 SQLite 数据库