zoukankan      html  css  js  c++  java
  • Git 应用问题(一) —— failed to push some refs to git

    今天在本地创建了一个新的 repository,想关联到 Github 上的时候出现问题,如下:

    Gerrard@LAPTOP-79570TK2 MINGW64 /g/github-workspace/jdbc (master)
    $ git push --set-upstream origin master
    To github.com:Gerrard-Feng/jdbc.git
     ! [rejected]        master -> master (fetch first)
    error: failed to push some refs to 'git@github.com:Gerrard-Feng/jdbc.git'
    hint: Updates were rejected because the remote contains work that you do
    hint: not have locally. This is usually caused by another repository pushing
    hint: to the same ref. You may want to first integrate the remote changes
    hint: (e.g., 'git pull ...') before pushing again.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.
    

    在网上搜索了一下这个错误:https://blog.csdn.net/u014470581/article/details/51490480

    发现是因为远程仓库创建的时候有 README.md 这个文件,而本地没有,从而导致 push 出错。

    那么解决问题就很简单了,把远程分支上的 README.md 拉下来:

    Gerrard@LAPTOP-79570TK2 MINGW64 /g/github-workspace/jdbc (master)
    $ git pull --rebase origin master
    warning: no common commits
    remote: Counting objects: 3, done.
    remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
    Unpacking objects: 100% (3/3), done.
    From github.com:Gerrard-Feng/jdbc
     * branch            master     -> FETCH_HEAD
     * [new branch]      master     -> origin/master
    First, rewinding head to replay your work on top of it...
    Applying: First commit.
    

    重新 push,问题解决!

    这里还有一个插曲,最初我试图在提交的时候带上一个10MB 的大文件,导致 push 卡死,将这个文件移除 commit 才提交成功。

    Gerrard@LAPTOP-79570TK2 MINGW64 /g/github-workspace/jdbc (master)
    $ git push --set-upstream origin master
    Counting objects: 50, done.
    Delta compression using up to 8 threads.
    Compressing objects: 100% (38/38), done.
    Writing objects: 100% (50/50), 10.95 KiB | 533.00 KiB/s, done.
    Total 50 (delta 4), reused 0 (delta 0)
    remote: Resolving deltas: 100% (4/4), done.
    To https://github.com/Gerrard-Feng/jdbc.git
       53b58c8..ef84230  master -> master
    Branch 'master' set up to track remote branch 'master' from 'origin'.
    
  • 相关阅读:
    Ubuntu 16.04安装Guake Terminal终端(使用一键唤醒功能)
    MySQL查询count(*)、count(1)、count(field)的区别收集
    MySQL查询在一个表而不在另一个表中的数据
    Spring MVC中的拦截器/过滤器HandlerInterceptorAdapter的使用
    Spring mvc解析
    RestTemplate的一个请求过程,mark一下
    福袋开发迭代总结
    Rest分享
    写Markdown费事?Typora让你像写word一样行云流水,所见即所得。
    送你几个用起来很爽的Studio插件
  • 原文地址:https://www.cnblogs.com/jing-an-feng-shao/p/9222477.html
Copyright © 2011-2022 走看看