当前位置: 代码迷 >> 综合 >> 向github中提交代码报错 Updates were rejected because the remote contains work that you do
  详细解决方案

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

热度:19   发布时间:2024-01-25 12:31:04.0

在向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 //把本地仓库的文件推送到远程仓库

 

  相关解决方案