Updates were rejected because the remote contains work that you do

每次建立新的仓库,提交的时总会出现这样的错误,真是头疼,......

直接开始正题,git 提交的步骤:

1. git init //初始化仓库

2. git add .(文件name) //添加文件到本地仓库

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

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

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

提交之后就会出现以下错误

要想解决以上错误,只需要在4,5之间使用git pull origin master即可

正确步骤:

1. git init //初始化仓库

2. git add .(文件name) //添加文件到本地仓库

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

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

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

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

OK

搞定,回家吃饭!!

时间: 2024-08-29 13:26:01

Updates were rejected because the remote contains work that you do的相关文章

(转)Updates were rejected because the tip of your current branch is behind

刚创建的github版本库,在push代码时出错: $ git push -u origin masterTo [email protected]:******/Demo.git ! [rejected] master -> master (non-fast-forward)error: failed to push some refs to '[email protected]:******/Demo.git'hint: Updates were rejected because the ti

解决 failed to push some refs to '[email protected]:zle1992/head-first-java' hint: Updates were rejected because the tip of your curr

问题描述: 寒假之前用实验室电脑push到github 上head first java 的程序,寒假回家后,想用自己的笔记本继续编,继续push . 我先从github下载zip到本地,然后 解压后,继续编程,但是用git push origin master 出现问题如下: 试了很多方法,最终解决方案如下: 思路: 新建一个文件夹,用pull 命令把文件从github下载下来,编写好新的程序,git add  git commit  git push 参考: http://www.tuico

Updates were rejected because the tip of your current branch is behind

有如下几种解决方法: 1.使用强制push的方法: $ git push -u origin master -f 这样会使远程修改丢失,一般是不可取的,尤其是多人协作开发的时候. 2.push前先将远程repository修改pull下来 $ git pull origin master $ git push -u origin master 3.若不想merge远程和本地修改,可以先创建新的分支: $ git branch [name] 然后push $ git push -u origin

git提交时报错:Updates were rejected because the tip of your current branch is behind

有如下3种解决方法: 1.使用强制push的方法:git push -u origin master -f这样会使远程修改丢失,一般是不可取的,尤其是多人协作开发的时候. 2.push前先将远程repository修改pull下来git pull origin mastergit push -u origin master 3.若不想merge远程和本地修改,可以先创建新的分支:git branch [name]然后pushgit push -u origin [name] 原文地址:https

VS2019 github push失败: Updates were rejected because the tip of your current branch is behind

解决方法: 创建新的分支,更改 ->同步->推送. 选中新创建的分支luelue(略略略),然后重复相同操作,在github页面上merge一下就行了. 原文地址:https://www.cnblogs.com/greenaway07/p/12584195.html

git提交远程报错[rejected] master -> master (fetch first)

1 先下载git for windows 然后一直点下一步安装. 2 安装之后,选择git gui.生成ssh 链接 git 公钥. 用命令也可以: $ ssh-keygen -t rsa -C "[email protected]" 然后输入密码. 建议用第一种方式.第二种网上说是可以,但是我没成功过. 然后输入密码. 3 将公钥添加到开源中国上,或者是github中 在开源中国中新建一个公钥,然后将.ssh文件夹下的id_ras_pub中的内容复制到文本框中,这里的title可以随

git本地仓库首次push到远程仓库出现错误 ! [rejected] master -> master (fetch first)

新建好本地的仓库和远程仓库之后, 经过git add . ,然后git commit -m "......", 最后想推送到远程仓库的时候git push -u origin master,出现下图错误 ! [rejected]        master -> master (fetch first) error: failed to push some refs to hint: Updates were rejected because the remote contain

【git基础】Permission denied (publickey). fatal: Could not read from remote repository

运行以下git命令的时候出现错误 git push -u origin master error The authenticity of host 'github.com (13.250.177.223)' can't be established. RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8. Are you sure you want to continue connecting (yes

本地git仓库和远端关联,创建一个新的项目提交到远端

创建远端项目           这个不用说了,在github或者本地的gitlab上创建,拿到ssh或者Https地址 创建本地仓库           1.新建文件夹,在文件夹内打开终端           2.初始化本地的文件夹为一个git可以管理的仓库                git init Initialized empty Git repository in X:/javaCode/workspace_MyBatis/.git/ 把本地仓库和远端仓库关联 $ git remo