一、情景
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. HDU 3072 Intelligence System(tarjan染色缩点+贪心+最小树形图)

    Intelligence System Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  2. cloudstack的虚拟机arp -a时网关的mac地址 都是Incomplete

    定位ARP攻击源头和防御方法 主动定位方式:因为所有的ARP攻击源都会有其特征——网卡会处于混杂模式,可以通过ARPKiller这样的工具扫描网内有哪台机器的网卡是处于混杂模式的,从而判断这台机器有可 ...

  3. OO第9~11次作业总结

    规格化设计调研 大致发展历史 --> 自给自足的私人化的软件生产方式. --> 落后的软件生产方式无法满足迅速增长的计算机软件需求,软件的开发与维护出现一系列严重问题. --> 正式 ...

  4. 20155204 王昊《网络对抗技术》EXP2 后门原理与实践

    20155204 王昊<网络对抗技术>EXP2 后门原理与实践 一.实验内容 准备工作(试用ncat.socat) 1. 使用netcat获取主机操作Shell,cron启动. 明确目标: ...

  5. cli 开发记录

    最近要开发一个 cli,主要作用是方便同事生成前端项目,做了一天半,基本参考的是 vue-cli. cli 要实现的功能: 用 cnpm install zt-cli -g 全局安装,这个就要将你做的 ...

  6. POJ2274

    这真的是一道数据结构的好题. 题意是在一条直线上有n辆车,每辆车有一个初始位置x[i]和速度v[i],问最终(在无限时间后)一共会发生多少次超车事件(mod 1000000),以及输出这些事件(如果大 ...

  7. LCA的一些算法

    LCA,就是求树上任意两点的最近公共祖先 (本题图片与代码均为Luogu3379) 方法我好像讲过一个,这次把主要的三个一起讲一讲 <1> 倍增(O(n log n)) 我们先考虑最基本的 ...

  8. windows系统中Dotnet core runtime 安装后,无法启动次程序,因为计算机中丢失api-ms-win-crt-runtime-l1-1-0.dll的解决方法

    因为dotnet core runtime依赖vc++2015,如果系统未安装vc++2015则会报上面的错误 解决方案:先下载安装vc++2015再安装dotnet core runtime, vc ...

  9. 大白话说Java泛型:入门、使用、原理

    文章首发于[博客园-陈树义],点击跳转到原文<大白话说Java泛型:入门.使用.原理> 远在 JDK 1.4 版本的时候,那时候是没有泛型的概念的.当时 Java 程序员们写集合类的代码都 ...

  10. Markdown 编辑器

    桌面编辑器 MarkdownPad Pro 版注册邮箱: Soar360@live.com 授权密钥: GBPduHjWfJU1mZqcPM3BikjYKF6xKhlKIys3i1MU2eJHqWGI ...