今天在本地创建了一个新的 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'.

Git 应用问题(一) —— failed to push some refs to git的更多相关文章

  1. git报错:failed to push some refs to 'git@github.com:JiangXiaoLiang1988/CustomerHandl

    一.错误信息 今天在使用git将代码上传到GitHub的时候报下面的错误: 以前上传代码的时候重来没有出现这种错误,在网上查找了半天终于找到原因了:github中的README.md文件不在本地代码目 ...

  2. 解决failed to push some refs to git

    Administrator@PC-20150110FGWU /K/cocos2d/yc (master) $ git push -u origin master To git@github.com:y ...

  3. git中failed to push some refs to git问题解决及基本使用

    国庆归来准备试用一下git,在提交代码时遇到时遇到一些问题 提交时使用git push origin master 出现failed to push some refs to git 回想一下,创建该 ...

  4. 由于github仓库中提前建立readme文件,导致git push报错error: failed to push some refs to 'git@github.com:

    $ git push -u origin master To git@github.com:xxx/xxx.git ! [rejected] master -> master (fetch fi ...

  5. 如何解决failed to push some refs to git

    $ git push -u origin master To git@github.com:yangchao0718/cocos2d.git ! [rejected]        master -& ...

  6. git push报错error: failed to push some refs to 'git@github.com'

    git push报错error: failed to push some refs to 'git@github.com' $ git push -u origin master To git@git ...

  7. [转载]如何解决failed to push some refs to git

    Administrator@PC-20150110FGWU /K/cocos2d/yc (master) $ git push -u origin master To git@github.com:y ...

  8. failed to push some refs to 'git@github.com:xxx/xxx.git' 解决方法

    此时很多人会尝试下面的命令把当前分支代码上传到master分支上. $ git push -u origin master 但依然没能解决问题 会出现: failed to push some ref ...

  9. failed to push some refs to 'git@github.com:RocsSun/mytest.git

    Git推送到GitHub仓库失败 使用Git将文件推送至GitHub的远程仓库时,报错failed to push some refs to 'git@github.com:RocsSun/mytes ...

随机推荐

  1. js修改文档的样式

    <!DOCTYPE html><html><head><meta charset="UTF-8"><title>Java ...

  2. HDU 4055 The King’s Ups and Downs(DP计数)

    题意: 国王的士兵有n个,每个人的身高都不同,国王要将他们排列,必须一高一矮间隔进行,即其中的一个人必须同时高于(或低于)左边和右边.问可能的排列数.例子有1千个,但是最多只算到20个士兵,并且20个 ...

  3. Codeforces 724 G Xor-matic Number of the Graph 线性基+DFS

    G. Xor-matic Number of the Graph http://codeforces.com/problemset/problem/724/G 题意:给你一张无向图.定义一个无序三元组 ...

  4. python基础教程总结8——特殊方法,属性,迭代器,生成器,八皇后问题

    1. 重写一般方法和特殊的构造方法 1.1 如果一个方法在B类的一个实例中被调用(或一个属性被访问),但在B类中没有找到该方法,那么会去它的超类A里面找. class A: ... def hello ...

  5. UVA225 Golygons 黄金图形(dfs+回溯)

    剪枝1:在同一个维度上的点具有相同的奇偶性,如果奇数数量只有奇数个那么一定不能返回原点. 剪枝2:当前位置怎么也走不回去. 3:沿途判断障碍即可. 在oj上提交0.347s,最快的0.012s,应该有 ...

  6. 1968: C/C++经典程序训练6---歌德巴赫猜想的证明

    1968: C/C++经典程序训练6---歌德巴赫猜想的证明 Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 1165  Solved: 499[Submi ...

  7. Python基础篇 -- 集合

    set集合 set 中的元素是不重复的,无序的 里面的元素必须是可hash的,(int str tuple bool) set 就是dict 类型的数据,但是不保存value 只保存 key set集 ...

  8. atoi 函数实现

      要考虑的东西实在也挺多的.总结如下:   1 前面空格分隔符号的时候   2 第一个符号位处理+ -   3 遇到非数字字符退出   4 为正数的时候,大于INT_MAX上溢   5 为负数的时候 ...

  9. 数据结构C语言实现系列——线性表(单向链表)

    #include <stdio.h> #include <stdlib.h> #define NN 12 #define MM 20 typedef int elemType ...

  10. LeetCode_6

    问题: 6. Z字形变换 链接:https://leetcode-cn.com/problems/zigzag-conversion/description/ 分析: A 仿真方法 直接模拟整个过程, ...