• Updates were rejected because the tip of your current branch is behind


    最近本地一个flutter项目因为当时使用可视化创建的时候出了一些问题,但是起初没有注意,后来因为需要新增一个语音插件,需要修改原生android MainActivity.java,才发现这个目录根本不存在,于是重新创建一个项目将原来那个项目文件拷入,等修改好后再使用git 连接原来那个项目的github仓库进行代码推送,发现老是提示如下错误

    
    	$ git push -u origin master
    	To https://github.com/dengxiaoning/flutter-trip.git
    	 ! [rejected]        master -> master (non-fast-forward)
    	error: failed to push some refs to 'https://github.com/dengxiaoning/flutter-trip.git'
    	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.
    
    
    

    然后又使用pull 仓库代码拉取合并,但是推送任然失败,看有朋友说需要 增加 -f 进行强制拉取,但是试过也没用,最后反过来想来过强制推送看得行不

    
    	$ git push -f origin master
    	Counting objects: 173, done.
    	Delta compression using up to 4 threads.
    	Compressing objects: 100% (130/130), done.
    	Writing objects: 100% (173/173), 1.66 MiB | 5.73 MiB/s, done.
    	Total 173 (delta 9), reused 38 (delta 4)
    	remote: Resolving deltas: 100% (9/9), done.
    	To https://github.com/dengxiaoning/flutter-trip.git
    	 + d137bd8...0208d12 master -> master (forced update)
    
    

    一试咦还OK了,不错记录记录。

    【注意】在协调时慎用,该参数-f会使用本地项目完全替换掉原仓库的项目,如果本地项目不能保证比远程仓库的完整切勿使用,否则追悔莫及

    看看官方介绍

    
    	-f--force
    	Usually, the command refuses to update a remote ref that is not an ancestor of the local ref used to overwrite it. Also, when --force-with-lease option is used, the command refuses to update a remote ref whose current value does not match what is expected.
    	
    	
    	This flag disables these checks, and can cause the remote repository to lose commits; use it with care.
    	
    	
    	Note that --force applies to all the refs that are pushed, hence using it with push.default set to matching or with multiple push destinations configured with remote.*.push may overwrite refs other than the current branch (including local refs that are strictly behind their remote counterpart). To force a push to only one branch, use a + in front of the refspec to push (e.g git push origin +master to force a push to the master branch). See the <refspec>... section above for details.
    
    
    
  • 相关阅读:
    spring3.1, hibernate4.1 配置备份,struts2.2.1,sitemesh 2.4.2
    java 动态AOP
    制作可以执行的 JAR 文件包及 jar 命令详解
    struts result Annotation 参考
    Android线段与矩形碰撞检测函数
    防止aspxspy木马列服务 iis信息 执行命令提权等操作
    博客园申请及页面定制CSS
    C# 中将月份格式化为英语缩写格式
    通过Web Service获取天气预报并朗读
    windows下html/javascript调用可执行程序
  • 原文地址:https://www.cnblogs.com/dengxiaoning/p/12309579.html
Copyright © 2020-2023  润新知