git 报错 :Updates were rejected because the tip of your current branch is behind 解决方法

git 报错 :Updates were rejected because the tip of your current branch is behind 解决方法

 

 报错

hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

博主:第一次新增了一个仓库并且仓库中新增readme的文件。

  首次次将本地的文件上传git仓库,到了最后一步git push origin master就报上面的错误。

报错原因:因为远程仓库有的文件,本地没有。因此报错

第一种解决办法:删除远程git仓库的文件,再进行推

第二种强制推送并且覆盖远程git仓库:git push -f origin master

注意:千万不要用:git pull --rebase origin master这个命令,这个命令,拉远程git仓库文件,并且覆盖本地文件。因此就会把我们本地还没有上传git的文件给覆盖掉,我们本地写的东西就没了

 

上一篇:dos语言


下一篇:[笔记] 树形问题