向github中提交代码报错 Updates were rejected because the remote contains work that you do

在向github中并非第一次提交代码时,提交代码被拒绝,提示如下:

Updates were rejected because the remote contains work that you do

解决办法:先pull一下远程仓库的代码,

 git pull origin master // 把本地仓库的变化连接到远程仓库主分支

然后再提交:

 git push -u origin master //把本地仓库的文件推送到远程仓库(简写:git pull);

提交代码的全部步骤:

1. git init //初始化仓库

2. git add * //添加文件到本地仓库

3. git commit -m "first commit" //添加文件描述信息

4. git remote add origin + 远程仓库地址 //链接远程仓库,创建主分支

5. git pull origin master // 把本地仓库的变化连接到远程仓库主分支

6. git push -u origin master //把本地仓库的文件推送到远程仓库

发布了90 篇原创文章 · 获赞 17 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/yinge0508/article/details/104020268
今日推荐