Git 技术篇 - 同步代码到github失败,提示non-fast-forward、error: failed to push some refs to问题解决方法,git pull的用法

简介: Git 技术篇 - 同步代码到github失败,提示non-fast-forward、error: failed to push some refs to问题解决方法,git pull的用法

     

因为 github 上仓库里删过一些内容,导致本地的仓库和 github 里的对不上了。

此时用 git push 操作就会报 non-fast-forwarderror: failed to push some refs to 的错误,这也是 git 安全机制的一部分。

image.png

所以我们只需要进行下 git pull origin master 就行了,其中 origin 指的是仓库源,master 指的是分支。

git pull origin master 就相当于:

$ git fetch origin master   #  从github上抓取代码到本地
$ git merge origin FETCH_HEAD    # 与本地代码进行合并

执行过程中会弹出这样一个编辑框,可以用来记录此次调整的改动。

编辑方法如果不会可以看这篇文章:

Linux 技术篇-使用vim命令创建、编辑文件内容实例演示,linux修改文档方法

image.png

都做完了,再进行 git add、git commit、git push 操作重新同步就可以了。

强制同步方法:

如果 git push 加个 -f–force 参数可以强制进行同步。

下面是整个操作的完整过程:

小蓝枣+Administrator@С▒▒▒▒ MINGW64 /c/Py_jupyter (master)
$ git push -u origin master
To https://github.com/2418546511/Py_jyputer.git/
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://2418546511:xxx@github.com/2418546511/Py_jyputer.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.
小蓝枣+Administrator@С▒▒▒▒ MINGW64 /c/Py_jupyter (master)
$ git pull origin master
From https://github.com/2418546511/Py_jyputer
 * branch            master     -> FETCH_HEAD
Removing Java_Project/untitled1/untitled1.iml
Removing Java_Project/untitled1/.idea/modules.xml
Removing Java_Project/untitled1/.idea/misc.xml
Removing Java_Project/untitled1/.idea/libraries/workbench_workbenchLevel_1.xml
Removing Java_Project/untitled1/.idea/libraries/polardb_jdbc18.xml
Removing Java_Project/untitled1/.idea/.gitignore
Removing Java_Project/test/test.iml
Removing Java_Project/test/src/com/test/test/test.java
Removing Java_Project/test/src/com/test/test/readExcel.java
Removing Java_Project/test/src/com/test/test/SiKuliTest.java
Removing Java_Project/test/src/com/test/test/ReadFile.java
Removing Java_Project/test/src/com/test/test/ReadClipboard.java
Removing Java_Project/test/out/production/test/com/test/test/readExcel.class
Removing Java_Project/test/out/production/test/com/test/test/SiKuliTest.class
Removing Java_Project/test/.idea/modules.xml
Removing Java_Project/test/.idea/misc.xml
Removing Java_Project/test/.idea/compiler.xml
Removing Java_Project/test/.idea/.gitignore
Adding Java_Project/dbmanage/src/com/dbmanage/db/config.txt
Adding Java_Project/dbmanage/src/com/dbmanage/db/ReadFile.java
Adding Java_Project/dbmanage/src/com/dbmanage/db/ReadClipboard.java
Adding Java_Project/dbmanage/src/com/dbmanage/db/DBUpdate.java
Adding Java_Project/dbmanage/src/com/dbmanage/db/DBQuery.java
Adding Java_Project/dbmanage/src/com/dbmanage/db/DBMain.java
Adding Java_Project/dbmanage/src/com/dbmanage/db/DBConn.java
Adding Java_Project/dbmanage/src/META-INF/MANIFEST.MF
Adding Java_Project/dbmanage/out/production/dbmanage/com/dbmanage/db/config.txt
Adding Java_Project/dbmanage/out/production/dbmanage/com/dbmanage/db/ReadFile.class
Adding Java_Project/dbmanage/out/production/dbmanage/com/dbmanage/db/ReadClipboard.class
Adding Java_Project/dbmanage/out/production/dbmanage/com/dbmanage/db/ReadClipboard$Result.class
Adding Java_Project/dbmanage/out/production/dbmanage/com/dbmanage/db/DBUpdate.class
Adding Java_Project/dbmanage/out/production/dbmanage/com/dbmanage/db/DBQuery.class
Adding Java_Project/dbmanage/out/production/dbmanage/com/dbmanage/db/DBMain.class
Adding Java_Project/dbmanage/out/production/dbmanage/com/dbmanage/db/DBConn.class
Adding Java_Project/dbmanage/out/production/dbmanage/META-INF/MANIFEST.MF
Adding Java_Project/dbmanage/out/artifacts/dbmanage_jar/dbmanage.jar
Adding Java_Project/dbmanage/dbmanage.iml
Adding Java_Project/dbmanage/.idea/vcs.xml
Adding Java_Project/dbmanage/.idea/uiDesigner.xml
Adding Java_Project/dbmanage/.idea/modules.xml
Adding Java_Project/dbmanage/.idea/misc.xml
Adding Java_Project/dbmanage/.idea/compiler.xml
Adding Java_Project/dbmanage/.idea/artifacts/dbmanage_jar.xml
Adding Java_Project/dbmanage/.idea/.gitignore
Removing Java_Project/databaseTool/databaseTool.iml
Removing Java_Project/databaseTool/.idea/modules.xml
Removing Java_Project/databaseTool/.idea/misc.xml
Removing Java_Project/databaseTool/.idea/.gitignore
Merge made by the 'recursive' strategy.
 Java_Project/databaseTool/.idea/.gitignore         |   3 -
 Java_Project/databaseTool/.idea/misc.xml           |   6 --
 Java_Project/databaseTool/.idea/modules.xml        |   8 ---
 Java_Project/databaseTool/databaseTool.iml         |  11 ---
 Java_Project/test/.idea/.gitignore                 |   3 -
 Java_Project/test/.idea/compiler.xml               |   6 --
 Java_Project/test/.idea/misc.xml                   |   6 --
 Java_Project/test/.idea/modules.xml                |   8 ---
 .../production/test/com/test/test/SiKuliTest.class | Bin 1234 -> 0 bytes
 .../production/test/com/test/test/readExcel.class  | Bin 3730 -> 0 bytes
 .../test/src/com/test/test/ReadClipboard.java      |  63 -----------------
 Java_Project/test/src/com/test/test/ReadFile.java  |  38 -----------
 .../test/src/com/test/test/SiKuliTest.java         |  26 -------
 Java_Project/test/src/com/test/test/readExcel.java |  76 ---------------------
 Java_Project/test/src/com/test/test/test.java      |  35 ----------
 Java_Project/test/test.iml                         |  29 --------
 Java_Project/untitled1/.idea/.gitignore            |   3 -
 .../untitled1/.idea/libraries/polardb_jdbc18.xml   |   9 ---
 .../.idea/libraries/workbench_workbenchLevel_1.xml |   9 ---
 Java_Project/untitled1/.idea/misc.xml              |   6 --
 Java_Project/untitled1/.idea/modules.xml           |   8 ---
 Java_Project/untitled1/untitled1.iml               |  13 ----
 22 files changed, 366 deletions(-)
 delete mode 100644 Java_Project/databaseTool/.idea/.gitignore
 delete mode 100644 Java_Project/databaseTool/.idea/misc.xml
 delete mode 100644 Java_Project/databaseTool/.idea/modules.xml
 delete mode 100644 Java_Project/databaseTool/databaseTool.iml
 delete mode 100644 Java_Project/test/.idea/.gitignore
 delete mode 100644 Java_Project/test/.idea/compiler.xml
 delete mode 100644 Java_Project/test/.idea/misc.xml
 delete mode 100644 Java_Project/test/.idea/modules.xml
 delete mode 100644 Java_Project/test/out/production/test/com/test/test/SiKuliTest.class
 delete mode 100644 Java_Project/test/out/production/test/com/test/test/readExcel.class
 delete mode 100644 Java_Project/test/src/com/test/test/ReadClipboard.java
 delete mode 100644 Java_Project/test/src/com/test/test/ReadFile.java
 delete mode 100644 Java_Project/test/src/com/test/test/SiKuliTest.java
 delete mode 100644 Java_Project/test/src/com/test/test/readExcel.java
 delete mode 100644 Java_Project/test/src/com/test/test/test.java
 delete mode 100644 Java_Project/test/test.iml
 delete mode 100644 Java_Project/untitled1/.idea/.gitignore
 delete mode 100644 Java_Project/untitled1/.idea/libraries/polardb_jdbc18.xml
 delete mode 100644 Java_Project/untitled1/.idea/libraries/workbench_workbenchLevel_1.xml
 delete mode 100644 Java_Project/untitled1/.idea/misc.xml
 delete mode 100644 Java_Project/untitled1/.idea/modules.xml
 delete mode 100644 Java_Project/untitled1/untitled1.iml
小蓝枣+Administrator@С▒▒▒▒ MINGW64 /c/Py_jupyter (master)
$ git add Java_Project
小蓝枣+Administrator@С▒▒▒▒ MINGW64 /c/Py_jupyter (master)
$ git commit -m "update java project 6.30"
[master 37e0f83] update java project 6.30
 3 files changed, 324 insertions(+)
 create mode 100644 Java_Project/databaseTool/.idea/workspace.xml
 create mode 100644 Java_Project/test/.idea/workspace.xml
 create mode 100644 Java_Project/untitled1/.idea/workspace.xml
小蓝枣+Administrator@С▒▒▒▒ MINGW64 /c/Py_jupyter (master)
$ git push -u origin master
Enumerating objects: 76, done.
Counting objects: 100% (76/76), done.
Delta compression using up to 16 threads
Compressing objects: 100% (50/50), done.
error: RPC failed; curl 55 SSL_write() returned SYSCALL, errno = 10053
fatal: the remote end hung up unexpectedly 88.00 KiB/s
Writing objects: 100% (67/67), 21.22 MiB | 346.00 KiB/s, done.
Total 67 (delta 9), reused 0 (delta 0)
fatal: the remote end hung up unexpectedly
Everything up-to-date

喜欢的点个赞❤吧!


目录
相关文章
|
1月前
|
开发工具 git
git如何修改提交代码时的名字和邮箱?
git如何修改提交代码时的名字和邮箱?
88 4
|
1月前
|
Java Linux 开发工具
IDEA中git提交前如何关闭code analysis以及开启格式化代码
【10月更文挑战第12天】本文介绍了在 IntelliJ IDEA 中关闭代码分析和开启代码格式化的步骤。关闭代码分析可通过取消默认启用检查或针对特定规则进行调整实现,同时可通过设置 VCS 静默模式在提交时跳过检查。开启代码格式化则需在 `Settings` 中配置 `Code Style` 规则,并通过创建 Git 钩子实现提交前自动格式化。
323 3
|
2月前
|
安全 网络安全 开发工具
深入探索Git:全面解析Git的用法与最佳实践
深入探索Git:全面解析Git的用法与最佳实践
61 2
|
1月前
|
JavaScript 前端开发 开发工具
一身反骨的我,用--no-verify绕开了git代码提交限制!
【10月更文挑战第7天】一身反骨的我,用--no-verify绕开了git代码提交限制!
111 0
|
2月前
|
Shell 网络安全 开发工具
fatal: unable to access 'https://github.com/wolfcw/libfaketime.git/': Encountered end of file
fatal: unable to access 'https://github.com/wolfcw/libfaketime.git/': Encountered end of file
|
3月前
|
存储 开发工具 git
|
21天前
|
缓存 Java Shell
[Git]入门及其常用命令
本文介绍了 Git 的基本概念和常用命令,包括配置、分支管理、日志查看、版本回退等。特别讲解了如何部分拉取代码、暂存代码、删除日志等特殊需求的操作。通过实例和图解,帮助读者更好地理解和使用 Git。文章强调了 Git 的细节和注意事项,适合初学者和有一定基础的开发者参考。
42 1
[Git]入门及其常用命令
|
3月前
|
开发工具 git
【GIT 第二篇章】GIT常用命令
Git常用命令涵盖初始化、状态管理、提交、分支处理、远程操作等关键流程。`git init`启动本地仓库,`git clone`下载远程仓库。通过`git status`和`git diff`检查工作状态与差异。利用`git add`暂存文件,`git commit`保存更改。借助`git branch`、`git checkout`、`git merge`和`git rebase`管理分支。使用`git fetch`、`git pull`和`git push`同步远程仓库。通过`git reset`、`git revert`和`git checkout`实现版本回退。
71 0
|
1月前
|
开发工具 git
git学习四:常用命令总结,包括创建基本命令,分支操作,合并命令,压缩命令,回溯历史命令,拉取命令
这篇文章是关于Git常用命令的总结,包括初始化配置、基本提交、分支操作、合并、压缩历史、推送和拉取远程仓库等操作的详细说明。
116 1
git学习四:常用命令总结,包括创建基本命令,分支操作,合并命令,压缩命令,回溯历史命令,拉取命令
|
25天前
|
开发工具 git 开发者
下一篇
无影云桌面