一、情景
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. 清北学堂寒假集训DAY1

    第一天,上午讲了些基本的技巧和简单算法,主要就是适应这里. 中午跑到食堂吃了顿“饭”(我并没有挖苦233333),然后回宿舍休息休息 因为 迎接我们的是模拟啊啊啊啊啊阿 下午题一发下来,并没有想象中的 ...

  2. 前端性能优化:Add Expires headers

    前端性能优化:Add Expires headers Expires headers 是什么? Expires headers:直接翻译是过期头.Expires headers 告诉浏览器是否应该从服 ...

  3. Android 将系统的back键模拟成为home键的功能

    @Override public void onBackPressed() { Intent intent = new Intent(Intent.ACTION_MAIN); intent.setFl ...

  4. ubuntu系统中添加DNS服务器地址后诡异消失的解决办法

    今天查看了一下自己电脑里的ubuntu14.04系统,发现无法上网,于是ping了一下百度,出现unknown host,查了一下/etc/resolv.conf中的DNS地址,却发现我之前的修改被清 ...

  5. 【H5】滚动事件(jq)

    $(function(){ console.log($('html,body').scrollTop());  //记录滚动高度(滚动前) }) $('html,body').scroll(funct ...

  6. Android应用安全之WEB接口安全

    Android应用安全不仅包括客户端的安全,也包括web接口的安全.移动App中的Web接口安全主要分为以下几块: 1.SQL注入漏洞 这是一个不能再常见的漏洞类型了,由于App的特性,开发人员认为使 ...

  7. SQL Server 启动时发生错误1069:由于登录失败而无法启动

    解决方法:    (1). 我的电脑--控制面板--管理工具--服务--右键MSSQLSERVER--属性--登陆--登陆身份--选择"本地系统帐户".    (2). 我的电脑- ...

  8. springboot redis 监听过期key值事件

    redis 中的key值过期后,触发通知事件 1.创建springboot工程,创建监听类 maven配置 <dependencies> <dependency> <gr ...

  9. POJ 2965&&1753

    最近由于复习备考(然而考得还是很炸),很久没打题目了.现在开始刷寒假作业,不得不搞POJ 话说没有中文真的好烦啊! 先看1753 题目大意是说在一个4*4的格子中有黑白两色的棋子,你可以翻动其中的棋子 ...

  10. Oracle出现与并行相关的ORA-00600时的调查方法

    出现了 ORA-00600[kxfpqsod_qc_sod], 如何调查呢? 例如:从trace 文件的 Call Stack,可以看到 Error: ORA-600 [kxfpqsod_qc_sod ...