zoukankan      html  css  js  c++  java
  • git pull fatal: refusing to merge unrelated histories

    1.首先我github有个远程仓库,然后我本地有个仓库

    本地仓库我新添加了一个文件,然后我去关联(git remote add origin git@github.com:qshilary/gittest.git)以后

    2.Git push发现报错了

    eqiasui@CN00214190 MINGW64 ~/Documents/practice (master)
    $ git push origin master
    Warning: Permanently added the RSA host key for IP address '13.250.177.223' to the list of known hosts.
    fatal: remote error:
    is not a valid repository name
    Email support@github.com for help

    eqiasui@CN00214190 MINGW64 ~/Documents/practice (master)
    $ git remote add origin git@github.com:qshilary/gittest.git
    fatal: remote origin already exists.

    eqiasui@CN00214190 MINGW64 ~/Documents/practice (master)
    $ git push origin master
    fatal: remote error:
    is not a valid repository name
    Email support@github.com for help

    3.然后我Git remote -v发现确实关联了,然后需要删除重新关联

    eqiasui@CN00214190 MINGW64 ~/Documents/practice (master)
    $ git remote -v
    origin git@github.com:qshilary/gittest.gitgit@github.com:qshilary/gittest.git (fetch)
    origin git@github.com:qshilary/gittest.gitgit@github.com:qshilary/gittest.git (push)

    eqiasui@CN00214190 MINGW64 ~/Documents/practice (master)
    $ git remote add origin git@github.com:qshilary/gittest.git

    4.再推发现还是报错了

    eqiasui@CN00214190 MINGW64 ~/Documents/practice (master)
    $ git push origin master
    To github.com:qshilary/gittest.git
    ! [rejected] master -> master (fetch first)
    error: failed to push some refs to 'git@github.com:qshilary/gittest.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.

    5.是因为远程已经有个工程了,但是我本地没有,所以肯定推不上去,需要Git pull一下

    eqiasui@CN00214190 MINGW64 ~/Documents/practice (master)
    $ git pull
    Warning: Permanently added the RSA host key for IP address '52.74.223.119' to the list of known hosts.
    warning: no common commits
    remote: Counting objects: 42, done.
    remote: Total 42 (delta 0), reused 0 (delta 0), pack-reused 42
    Unpacking objects: 100% (42/42), done.
    From github.com:qshilary/gittest
    * [new branch] master -> origin/master
    There is no tracking information for the current branch.
    Please specify which branch you want to merge with.
    See git-pull(1) for details.

    git pull <remote> <branch>

    If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

    6.Git pull发现报错了

    eqiasui@CN00214190 MINGW64 ~/Documents/practice (master)
    $ git branch --set-upstream-to=origin/master master
    Branch 'master' set up to track remote branch 'master' from 'origin'.

    eqiasui@CN00214190 MINGW64 ~/Documents/practice (master)
    $ git pull
    fatal: refusing to merge unrelated histories

    eqiasui@CN00214190 MINGW64 ~/Documents/practice (master)
    $ git pull origin master --allow-unrelated-histories
    From github.com:qshilary/gittest
    * branch master -> FETCH_HEAD
    Merge made by the 'recursive' strategy.
    Git-2.9.0-64-bit.exe | Bin 0 -> 31502824 bytes

    git在最新2.9.2,合并pull两个不同的项目,出现的问题如何去解决fatal: refusing to merge unrelated histories

    我在Github新建一个仓库,写了License,然后把本地一个写了很久仓库上传。

    先pull,因为两个仓库不同,发现refusing to merge unrelated histories,无法pull

    因为他们是两个不同的项目,要把两个不同的项目合并,git需要添加一句代码,在git pull,这句代码是在git 2.9.2版本发生的,最新的版本需要添加--allow-unrelated-histories

    假如我们的源是origin,分支是master,那么我们 需要这样写git pull origin master ----allow-unrelated-histories需要知道,我们的源可以是本地的路径

  • 相关阅读:
    HDOJ 3265 Posters (线段树+扫描线求矩形面积并)
    HDOJ 2243 考研路茫茫——单词情结(自动机DP+矩阵快速幂和)
    POJ 1389 Area of Simple Polygons (离散化求矩形面积并)
    POJ 3691 DNA repair(自动机DP)
    POJ 1151 Atlantis (离散化求矩形面积并)
    备份—何为备份?
    健康,人生第一要事
    x200 降噪手记
    好书推荐《系统管理员的时间管理》
    计算机加入域全过程截图
  • 原文地址:https://www.cnblogs.com/hilaryqs/p/9212758.html
Copyright © 2011-2022 走看看