创建 Github 存储库并仅通过 git 推送文件

Create Github repo and push files ONLY through git

有没有办法让 Git 创建一个 GitHub 存储库然后将文件推送到它的 master 分支?谢谢!

安装集线器,然后使用hub create

它将询问您的 github username/password,然后将使用您本地项目的目录名称创建 public 存储库。

https://hub.github.com

Git 本身不会创建远程 GitHub 存储库。
只有 GitHub API can do that.

例如,无需安装任何 GitHub API 包装器,使用来自 git bash:

a command like
curl -u 'github-username' https://api.github.com/user/repos -d '{"name":"repo-name"}'

然后,在您的本地存储库中:

git remote add origin https://github.com/github-username/repo-name.git