本地git仓库关联github仓库后无法push
2017-01-11 10:38
399 查看
在Github上新建一个仓库后有以下指导
…or create a new repository on the command line
echo “# learn_git” >> README.md
git init
git add README.md
git commit -m “first commit”
git remote add origin https://github.com/hcz017/learn_git.git
git push -u origin master
…or push an existing repository from the command line
git remote add origin https://github.com/hcz017/learn_git.git
git push -u origin master
现在的情况是本地有一个已经存在的仓库,但是push不到github上。
1.先删掉以前关联的的远程仓库
2.添加新的远程仓库地址
…or create a new repository on the command line
echo “# learn_git” >> README.md
git init
git add README.md
git commit -m “first commit”
git remote add origin https://github.com/hcz017/learn_git.git
git push -u origin master
…or push an existing repository from the command line
git remote add origin https://github.com/hcz017/learn_git.git
git push -u origin master
现在的情况是本地有一个已经存在的仓库,但是push不到github上。
1.先删掉以前关联的的远程仓库
$ git remote remove origin
2.添加新的远程仓库地址
$ git remote add origin https://github.com/hcz017/learn_git.git[/code]
3.push本地代码到远程$ git push -u origin master
这时候就报错了$ git push -u origin master error: src refspec master does not match any
试了好几次都这样,google也没查到解法,一般别人是因为本地没有代码才会有这个提示,但我现在本地有代码啊。
忽然意识到,可能是因为我没有master分支?(因为我本来就没有master分支,我一开始checkout出来的就是dev分支)
如果说指定了master分支的话,那我确实也可以算本地没有代码。检查一下我本地还真没有master分支。
本地新建一个master分支之后在push就成功了。$ git checkout -b master $ git push -u origin master
其实这是一个很低级的错误。就是对命令不熟悉,只知道照抄,加上我一开始没注意到本地分支名不是master。
可以看下面的解释$ git push origin master
上面命令表示,将本地的master分支推送到origin主机的master分支。如果后者不存在,则会被新建。
更多git内容可参考Git远程操作详解
相关文章推荐
- Git创建本地仓库以及关联github
- 无法推送一些引用到 'git@github.com:Apologise/DjangoSample.git' 提示:更新被拒绝,因为远程仓库包含您本地尚不存在的提交。这通常是因为另外 提示:一个仓库已向
- git本地仓库关联github仓库
- 关于本地Git仓库远程push至GitHub仓库
- windows如何设置本地git仓库与远程的github关联
- 本地Git仓库关联到远程GitHub仓库
- 无法再次从本地仓库push到github存储库问题
- 本地Git仓库关联Github项目
- 本地git仓库与GitHub远程仓库关联同步
- Git本地仓库与Github远程仓库关联
- Git 菜鸟变大神 (四)Github 创建远程仓库以及关联本地仓库
- 将本地git仓库上传到github仓库时出现error: src refspec master does not match any报错无法上传
- Git本地仓库关联GitHub远程仓库的一般步骤
- git将本地项目通过SSH来 push 到自己的GitHub仓库
- Git 创建github远程仓库并关联本地项目
- 使用Git将本地仓库与GitHub远程仓库相关联
- git本地仓库重新建立错误,无法push。
- Git的使用(本地仓库的设置,文件添加,关联github远程仓库)
- Eclipse与GitHub的整合(一)——本地Git仓库中的代码push至GitHub
- Git本地仓库push至GitHub远程仓库每次输入账户密码问题解决