use*_*079 11 git github repository
我一直在尝试从命令行将我的本地repo更改推送到github.我已经离开git一段时间了,所以我不记得一些事情.在过去的一小时里,我一直试图在没有在Github.com上创建远程仓库的情况下推销仓库.据我所知,git push origin master/git push足以推送本地更改,并在必要时在远程服务器上创建一个repo.但是git push不会让我推动并自动创建回购.
因此,为了节省时间,我在github.com上创建了远程仓库并使用添加远程仓库URL
git remote add origin https://mygithubrepoUrl.com
它起作用了.
是否有必要在Github上创建远程仓库,然后从命令行添加此URL以推送更改?Git不能自动创建repo并推送更改吗?
krl*_*mlr 16
您需要在推送之前创建存储库,但是hub可以为您自动执行此操作:
git init newRepo
cd newRepo
hub create
Run Code Online (Sandbox Code Playgroud)
使用-p开关hub create创建私有存储库.要推送本地master分支,请发出:
git push -u origin HEAD
Run Code Online (Sandbox Code Playgroud)
该工具还可以创建拉取请求,打开项目页面,检查CI状态,通过仅指定克隆现有的回购username/repo,以及更多内容.
该项目页面显示走样git到hub(因为后者向前未知命令git),但我不建议这样做,哪怕只是区分"裸"的Git从命令hub糖果.
Github API应该可以工作.
首先使用curl和API
https://developer.github.com/v3/repos/#create创建repo
就像是:
curl -u 'username' https://api.github.com/user/repos -d '{"name":"repository name"}'
然后你可以像之前描述的那样添加远程和推送:
git remote add origin git@github.com:user/repository_name.git && git push origin master
cli.github.com现在是 hub 的继承者。
创建一个新的 GitHub 存储库。
用法:
创建一个新的 GitHub 存储库。
使用 "
ORG/NAME" 语法在您的组织内创建存储库。用法:
Run Code Online (Sandbox Code Playgroud)gh repo create [<name>] [flags]标志:
Run Code Online (Sandbox Code Playgroud)-d, --description string Description of repository --enable-issues Enable issues in the new repository (default true) --enable-wiki Enable wiki in the new repository (default true) -h, --homepage string Repository home page URL --public Make the new repository public -t, --team string The name of the organization team to be granted access全局标志:
Run Code Online (Sandbox Code Playgroud)--help Show help for command -R, --repo OWNER/REPO Select another repository using the OWNER/REPO format
| 归档时间: |
|
| 查看次数: |
9489 次 |
| 最近记录: |