zoukankan      html  css  js  c++  java
  • git 解决 error: failed to push some refs to 'https://github.com/xxxx.git'

    在github远程创建仓库后, 利用gitbash进行提交本地文件的时候出现如下错误

    [root@foundation38 demo]# git push -u origin master
    Username for 'https://github.com': xuefeilong
    Password for 'https://xuefeilong@github.com': 
    To https://github.com/xuefeilong/test.git
     ! [rejected]        master -> master (non-fast-forward)
    error: failed to push some refs to 'https://github.com/xuefeilong/test.git'
    hint: Updates were rejected because the tip of your current branch is behind
    hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
    hint: before pushing again.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.
    

      解决办法:

    1: 进行push前先将远程仓库pull到本地仓库
    $ git pull origin master    #git pull --rebase origin master
    $ git push -u origin master
    
    2: 强制push本地仓库到远程 (这种情况不会进行merge, 强制push后远程文件可能会丢失 不建议使用此方法)
    $ git push -u origin master -f
    
    3: 避开解决冲突, 将本地文件暂时提交到远程新建的分支中
    $ git branch [name]
    # 创建完branch后, 再进行push
    $ git push -u origin [name] 
    

      我使用的是直接加入参数-f,但是不推荐比较粗暴:

    [root@foundation38 demo]# git push -u origin master -f
    Username for 'https://github.com': xuefeilong
    Password for 'https://xuefeilong@github.com': 
    Counting objects: 13, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (7/7), done.
    Writing objects: 100% (13/13), 975 bytes | 0 bytes/s, done.
    Total 13 (delta 1), reused 0 (delta 0)
    remote: Resolving deltas: 100% (1/1), done.
    To https://github.com/xuefeilong/test.git
     + 5c057df...abfded5 master -> master (forced update)
    Branch master set up to track remote branch master from origin.
    

      转载 自 https://blog.csdn.net/sgsgy5/article/details/83689516

  • 相关阅读:
    iOS开发网络篇—搭建本地服务器
    iOS开发网络篇—网络编程基础
    iOS开发多线程篇—基础知识 NSOperation
    iOS开发多线程篇—NSOperation基本操作
    iOS开发多线程篇—单例模式(ARC)
    iOS开发之多线程
    iOS开发多线程篇—GCD介绍
    iOS开发多线程篇—线程安全
    Object-C非正式协议与正式协议的区别
    objective-c中Category类别(扩展类)专题总结
  • 原文地址:https://www.cnblogs.com/qq735675958/p/11657088.html
Copyright © 2011-2022 走看看