[Problem] solutions can not pull git repository refusing to merge unrelated histories

Reference links

Problem Description

  • Pre-existing local warehouse and the new github repository association, and upload local warehouse.
  • First, after a init+ git remote add ..a series of steps associated
  • If you choose the protocol when GitHub building a database, you need to pull, this time in no git push -u ..case of, such as the title may be an error

problem analysis

  • If you combine two different starting a warehouse submitted, the new gitwill find two warehouses may not be the same, in order to prevent developers upload error, then gave the following tips

    • fatal: refusing to merge unrelated histories
  • New on Github as a warehouse, wrote License, and then write a local warehouse for a long time to upload. Then find github repository and not a local joint commitso git not to submit, that is the wrong origin, if the developer is determined that originyou can use --allow-unrelated-historiesto tell ourselves git

  • Encountered a problem can not be submitted, which is generally the first pull use git pull origin master

    • Here is the origin warehouse
    • master branch is required to upload
    • Because two different warehouses, found git output refusing to merge unrelated historiescan not pull content
  • Because they are two different projects, two different projects should merge, git you need to add a code, in git pullafter this code is happening in git 2.9.2 version, the latest version needs to be added --allow-unrelated-historiesto tell git allow irrelevant history merge

problem solved

  • If the source is the origin, the branch is master, then write:

    • git pull origin master --allow-unrelated-histories
  • If you have set a default upload branch can use the code below

    • git pull --allow-unrelated-histories

END

Guess you like

Origin www.cnblogs.com/anliux/p/12665839.html