一、情景
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. Android ListView下拉刷新时卡的问题解决小技巧

    问题:ListView下拉刷新时看上去非常的卡 解决方案: 在BaseAdapter的getView方法中,有三个参数 public View getView(int position, View c ...

  2. 【转】软件质量之道:SourceMonitor

    转:https://blog.csdn.net/feng_ma_niu/article/details/40594799 SourceMonitor是一个源代码衡量工具,由http://www.cam ...

  3. P1550 [USACO08OCT]打井Watering Hole

    题目描述 Farmer John has decided to bring water to his N (1 <= N <= 300) pastures which are conven ...

  4. stop-hbase.sh一直处于等待状态

    今天关闭HBase时,输入stop-hbase.sh一直处于等待状态 解决方法: 先输入:hbase-daemon.sh stop master 再输入:stop-hbase.sh就可以关闭HBase ...

  5. SharePoint2016配置工作流开发环境

    1,下载Web PlatForm5.0  地址:https://www.microsoft.com/web/downloads/platform.aspx 2,保证开发环境能连网,安装Web Plat ...

  6. 自定义View之实现流行的底部菜单栏中间突起:高仿“咸鱼APP”的底部菜单 - z

    http://blog.csdn.net/xh870189248/article/details/75808341 http://blog.csdn.net/yangg194/article/deta ...

  7. 20155216 Exp8 WEB基础实践

    Exp8 WEB基础实践 实践内容 Apache环境配置 apache是kali下的web服务器,通过访问 ip地址+端口号+文件名称 打开对应的网页. 输入命令 vi /etc/apache2/po ...

  8. 20155220 Exp9 Web安全基础实践

    Exp9 Web安全基础实践 实验过程 开启webgoat 输入java -jar webgoat-container-7.1-exec.jar,来运行webgoat 在浏览器输入localhost: ...

  9. 20155229《网络对抗技术》Exp9:Web安全基础

    实验内容 Webgoat实践下相关实验. 实验步骤 WebGoat: Webgoat是OWASP组织研究出的一个专门进行web漏洞实验的应用品台,这个平台里包含了web中常见的各种漏洞,例如:跨站脚本 ...

  10. 20155304《网络对抗》Exp2 后门原理与实践

    20155332<网络对抗>Exp2 后门原理与实践 实验内容 (3.5分) (1)使用netcat获取主机操作Shell,cron启动 (0.5分) (2)使用socat获取主机操作Sh ...