zoukankan      html  css  js  c++  java
  • git 提交代码报错failed to push some refs to 解决笔记

    Administrator@SC-201902081500 MINGW64 /e/gitrepository (master)
    $ git push django master
    To github.com:zgc137/django.git
     ! [rejected]        master -> master (non-fast-forward)
    error: failed to push some refs to 'git@github.com:zgc137/django.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.

    此时很多人会尝试下面的命令把当前分支代码上传到master分支上。

    $ git push -u origin master

    但依然没能解决问题

    出现错误的主要原因是github中的README.md文件不在本地代码目录中

    origin是自己在git上创建的仓库名字,我的创建的名字是django

    可以通过如下命令进行代码合并【注:pull=fetch+merge]---取+合并

    git pull --rebase origin master

    注:上传代码到远程库,上传之前最好先Pull一下,再执行命令: git pull origin master

    $ git pull --rebase django master
    Warning: Permanently added the RSA host key for IP address '52.74.223.119' to the list of known hosts.
    From github.com:zgc137/django
     * branch            master     -> FETCH_HEAD
    First, rewinding head to replay your work on top of it...
    Applying: wrote a readme file
    Applying: 天天生鲜项目+练习

    即pull成功,

    接着执行:git push origin master

    $ git push -u django master
    Enumerating objects: 115, done.
    Counting objects: 100% (115/115), done.
    Delta compression using up to 12 threads
    Compressing objects: 100% (111/111), done.
    Writing objects: 100% (114/114), 1.44 MiB | 782.00 KiB/s, done.
    Total 114 (delta 3), reused 0 (delta 0)
    remote: Resolving deltas: 100% (3/3), done.
    To github.com:zgc137/django.git
       eecd635..07115e0  master -> master
    Branch 'master' set up to track remote branch 'master' from 'django'.
  • 相关阅读:
    我的Git教程 之 初始化本地库
    再学Java 之 Integer 包装类缓存
    再学Java 之 private、protected、public和default的作用域
    再学Java 之 形参个数可变函数
    再学Java 之 foreach循环
    解决MySQL中文乱码问题
    再学Java 之 解决No enclosing instance of type * is accessible
    从一个例子学习 instanceof 和 getclass 的区别
    如何单独启动wamp 中自带的MySQL
    网络游戏程序员须知 UDP vs TCP(转)
  • 原文地址:https://www.cnblogs.com/jackzz/p/10849038.html
Copyright © 2011-2022 走看看