新建工程发布到github

1、工程目录下git init
2、git add .
3、git commit
4、建立github库,名称为:platform,得到库地址: https://github.com/gosenkle/platform.git
此时协议等信息都选择为none,保持整个工程为空的,否则无法从本地库上传。
5、关联库地址
git remote add origin https://github.com/gosenkle/platform.git
6、推送到github上
git push -u origin master
-u:初始化时因为内容是空,所以需要需要-u参数;后续可以省略
7、如果在建立github库时因为建立了如readme以及协议等信息,导致远程库并不是空的库,执行6时会发生如下错误
error: failed to push some refs to https://github.com/gosenkle/platform.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
如果此时执行git pull origin master会发生如下错误
fatal: refusing to merge unrelated histories
8、执行如下命令git pull origin master --allow-unrelated-histories,成功,后续可以执行6操作了。

9、创建本地分支并同步到远程库
1)本地执行git branch release
2)切换分支 git checkout release
3)将分支放到远程库:git push origin release


猜你喜欢

转载自blog.csdn.net/gosenkle/article/details/80043753