git pull fatal: refusing to merge unrelated histories

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

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

2.Git push发现报错了fetch

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 helpui

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

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

3.而后我Git remote -v发现确实关联了,而后须要删除从新关联orm

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)ci

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

4.再推发现仍是报错了it

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须要知道,咱们的源能够是本地的路径

相关文章
相关标签/搜索