远程仓库新建分支之后的问题

! [rejected] dev -> dev (fetch first)和! [rejected] dev -> dev (non-fast-forward)

  • 第一个问题这样解决:

    git fetch origin

    从远程仓库拉取

    结果有点像同步信息:

    D:\Idea\Project_Location\springcloud_nacos>git fetch origin
    remote: Enumerating objects: 3, done.
    remote: Counting objects: 100% (3/3), done.
    remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
    Unpacking objects: 100% (3/3), done.
    From github.com:StupidTomCat/springcloud_nacos
     * [new branch]      dev        -> origin/dev
    
  • 第二个问题这样解决:

    前提条件我已经提交过了

    # 获取远程 dev 分支的修改
    git fetch origin dev
     
    # 合并远程 dev 分支
    git merge origin dev
     
    #更新本地的代码
    git pull origin dev
    
    git pull origin dev --allow-unrelated-histories
    

    1)

    D:\Idea\Project_Location\springcloud_nacos>git fetch origin dev
    From github.com:StupidTomCat/springcloud_nacos
     * branch            dev        -> FETCH_HEAD
    

    2)

    D:\Idea\Project_Location\springcloud_nacos>git merge origin dev
    merge: origin - not something we can merge
    

    ​ 这个我笑了,呵呵

    3)

    D:\Idea\Project_Location\springcloud_nacos>git pull origin dev
    From github.com:StupidTomCat/springcloud_nacos
     * branch            dev        -> FETCH_HEAD
    fatal: refusing to merge unrelated histories
    

    ​ 继续笑

    4)

    D:\Idea\Project_Location\springcloud_nacos>git pull origin dev --allow-unrelated-histories
    From github.com:StupidTomCat/springcloud_nacos
     * branch            dev        -> FETCH_HEAD
    Merge made by the 'recursive' strategy.
     README.md | 1 +
     1 file changed, 1 insertion(+)
     create mode 100644 README.md
    

    ​ 渐渐好起来了

    5)

    D:\Idea\Project_Location\springcloud_nacos>git push origin dev
    Enumerating objects: 26, done.
    Counting objects: 100% (26/26), done.
    Delta compression using up to 4 threads
    Compressing objects: 100% (23/23), done.
    Writing objects: 100% (23/23), 3.10 KiB | 635.00 KiB/s, done.
    Total 23 (delta 10), reused 0 (delta 0)
    remote: Resolving deltas: 100% (10/10), completed with 1 local object.
    To github.com:StupidTomCat/springcloud_nacos.git
       fd8e991..0a73b5e  dev -> dev
    

    ​ 成功

小结

整件事的起因是我在gitHub上面新建了一个dev分支导致本地代码提交不上去,我笑了。

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页