今天在本地创建了一个新的 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. 无法启动 Diagnostic Policy Service(服务错误 1079)的解决方案

    问题 在services.msc中手动启动 Diagnostic Policy Service 时,弹出以下提示: ---------------------------服务------------- ...

  2. ubuntu开放端口

    1.安装iptables(一般情况,ubuntu安装好的时候,iptables会被安装上),使用以下命令: $apt-get update $apt-get install iptables 2.安装 ...

  3. 01_3_查询指定id的单个对象

    01_3_查询指定id的单个对象 1. 映射文件配置如下信息 <select id="selectStudentById" resultClass="Student ...

  4. UI Testing in Xcode 7

    参考文章: UI Testing in Xcode - WWDC 2015https://developer.apple.com/videos/play/wwdc2015-406/ Document ...

  5. iOS 开发 Xib 的嵌套使用

    最近公司项目需要使用 Xib 中嵌套 Xib来布局界面的, 研究了很久才实现!!! 分享给大家,希望帮助到更多的开发者...... 开发中自定义界面有两种方式 一: 纯代码实现 适合单个极度复杂的界面 ...

  6. IOS版本判断

    -(void)getIOSVersion { //#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 50000    //此方法和编译器相关 //quanju.iOS ...

  7. JavaScript递归实现对象深拷贝

    let personOne = { name:"张三", age:18, sex:"male", children:{ first:{ name:"z ...

  8. 关于在vue 中使用百度ueEditor

    1. 安装  npm i vue-ueditor --save-dev 2.从nodemodels  取出ueditor1_4_3_3 这整个目录,放入vue 的 static 目录 3.配置 ued ...

  9. Golang 简单web测试

    // mhoso project main.go package main import ( "log" "net/http" "./controll ...

  10. i2c drivers

    Linux设备驱动程序架构分析之一个I2C驱动实例   转载于:http://blog.csdn.net/liuhaoyutz 内核版本:3.10.1   编写一个I2C设备驱动程序的工作可分为两部分 ...