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須要知道,咱們的源能夠是本地的路徑

相關文章
相關標籤/搜索