一、情景
1.在GitHub上创建一个仓库A,并且初始化了readme.md这个文档.
2.在本地用Git Bash初始化仓库A(一开始没有从GitHub上拉下来).

git init /* 初始化一个空的仓库*/

3.在本地仓库新建一个文件 test.txt,并且提交到本地仓库.

git add test.txt /* 把test.txt设为仓库跟踪文件 */ 
git commit -m “测试第一次 test.txt” /* 提交文件并且追加备注 */

4.把本地仓库提交到远程仓库master 分支

git push git@github.com:用户名/仓库名 master 
提交失败:not have locally. This is usually caused by another repository push

二、原因
本地仓库跟远程仓库的版本不一样导致的,因为执行在步骤1的时候,远程的版本库会有个“commit readme.md”这个操作记录,本地仓库是不知道你有这个提交的,也就是说这个记录没在本地仓库是不存在的,所以俩个版本是不一致的.
三 、解决方法

A). 先更新本地版本在提交

  1. 利用 git pull 更新本地版本库.
  2. 再 利用git push命令把本地仓库推送至远程仓库.

B). 强制覆盖

  1. 加上 -f 参数 强制覆盖

git push -f

可以参考链接:http://stackoverflow.com/questions/20939648/issue-pushing-new-code-in-github

Git push -u orign master 提示hint: not have locally. This is usually caused by another repository push的更多相关文章

  1. hint: not have locally. This is usually caused by another repository pushing

    git 提交代码前先pull代码,否则会报如下错误 wangju@wangju-HP-348-G4:~/test/reponselogiccheck$ git statusOn branch mast ...

  2. Git error: hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused b

    hint: Updates were rejected because the remote contains work that you dohint: not have locally. This ...

  3. Git error: hint: Updates were rejected because the remote contains work that you do hint: not have locally

    hint: Updates were rejected because the remote contains work that you dohint: not have locally. This ...

  4. idea关联git后 Git上传项目提示Push rejected: Push to origin/master was rejected解决办法

    当所有的东西都配好以后  就是不上数据  解决方案是在所属右键 点击Git BashHere后  输入:git pull origin master –allow-unrelated-historie ...

  5. Git上传项目到码云提示Push rejected: Push to origin/master was rejected

    感谢大佬:https://blog.csdn.net/weixin_41499217/article/details/82985582 Push rejected: Push to origin/ma ...

  6. Push to origin/master was rejected (Git提交错误)

    [问题描述] 在使用Git Push代码的时候,会出现 Push to origin/master was rejected 的错误提示. 在第一次提交到代码仓库的时候非常容易出现,因为初始化的仓库和 ...

  7. Push to origin/master was rejected (Git提交错误)(转)

    [问题描述] 在使用Git Push代码的时候,会出现 Push to origin/master was rejected 的错误提示. 在第一次提交到代码仓库的时候非常容易出现,因为初始化的仓库和 ...

  8. Git出现提交错误--Push to origin/master was rejected(转)

    Step1:出现的问题? 在使用Git Push代码的时候,会出现Push to origin/master was rejected 的错误提示.在第一次提交到代码仓库的时候非常容易出现,因为初始化 ...

  9. git push -u origin master error: failed to push some refs to

    1.问题描述 $ git push -u origin master To github.com:[github_name]/[github_repository_name].git ! [rejec ...

随机推荐

  1. 计算机视觉-sift(1)原理

    1999年由David Lowe首先发表于计算机视觉国际会议(International Conference on Computer Vision,ICCV),2004年再次经David Lowe整 ...

  2. day44

    今日内容: 1.前端概述 2.前端三剑客 3.页面基本结构 4.常用标签 5.标签分类 1.前端概述与前端三剑客 前端即⽹站前台部分,运⾏在PC端,移动端等浏览器上展现给⽤户浏览的⽹⻚.随着互联⽹技术 ...

  3. Docker一键部署Hadoop心得(一)

    最近一直在折腾使用docker一键部署全分布式hadoop集群,虽然一键部署的脚本写好了并且可以成功运行出各个节点,但在运行一个wordcount实例时出现了错误,错误如下: java.io.IOEx ...

  4. WPF编程,窗体最大化、最小化、关闭按钮功能的禁用

    原文:WPF编程,窗体最大化.最小化.关闭按钮功能的禁用 版权声明:我不生产代码,我只是代码的搬运工. https://blog.csdn.net/qq_43307934/article/detail ...

  5. Luogu P1484 种树

    这道题目还是比较简单的 首先题目的意思就让我们很轻易地想到DP 我们设f[i][j]表示前i个坑中种j棵树的最大利益,则有: f[i][j]=max(f[i-1][j],f[i-2][j-1]+a[i ...

  6. POJ 2388&&2299

    排序(水题)专题,毕竟如果只排序不进行任何操作都是极其简单的. 事实上,排序算法十分常用,在各类高级的算法中往往扮演着一个辅助的部分. 它看上去很普通,但实际的作用却很大.许多算法在失去排序后将会无法 ...

  7. Luogu P1196 [NOI2002]银河英雄传说

    一年没写博客了(滑稽). 这道题很玄学,导致自己都有一个坑人的问题求解.如果有大佬有能力求帮助:https://www.luogu.org/discuss/show?postid=30231 再来讲一 ...

  8. Js_实现3D球体旋转

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  9. Docker部署Zookeeper容器

    获取zookeeper镜像 docker pull zookeeper 创建zookeeper容器 docker run --name="zookeeper" -p 2181:21 ...

  10. 初入Installshield2015

    首先我们来认识一下这款软件:这是一款功能强大的软件打包工具,有着许多强大的功能等着我们去发掘,博主也是最近被这个东西搞得有点晕头, 现在就想让读者朋友们更快的接受这个软件. 这个软件需要的破解工具,大 ...