Tag Archives: Git pull fatal

[Solved] Git pull fatal: refusing to merge unrelated histories

1. First I have a remote repository in github, then I have a local repository

I added a new file to my local repository, and then after I associated it (git remote add origin [email protected]:qshilary/gittest.git)

2. Git push found an error

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 [email protected] for help

eqiasui@CN00214190 MINGW64 ~/Documents/practice (master)
$ git remote add origin [email protected]: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 [email protected] for help

3. Then I found that Git remote -v was indeed associated, and then I needed to delete and re-associate it

eqiasui@CN00214190 MINGW64 ~/Documents/practice (master)
$ git remote -v
origin [email protected]:qshilary/[email protected]:qshilary/gittest.git (fetch)
origin [email protected]:qshilary/[email protected]:qshilary/gittest.git (push)

eqiasui@CN00214190 MINGW64 ~/Documents/practice (master)
$ git remote add origin [email protected]:qshilary/gittest.git

4. push again to find or report an error

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 ‘[email protected]: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. because the remote already has a project, but I do not have a local, so certainly can not push up, need to 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 Found an error reported

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 in the latest 2.9.2, merge pull two different projects, the problem appears how to go about solving fatal: refusing to merge unrelated histories

I created a new repository in Github, wrote License, and then uploaded a local repository that I had written for a long time.

First pull, because the two repositories are different, I found refusing to merge unrelated histories and couldn’t pull

Because they are two different projects, to merge two different projects, git needs to add a line of code in git pull, which happened in git version 2.9.2, the latest version needs to add --allow-unrelated-histories

If our source is origin and our branch is master, then we need to write git pull origin master ----allow-unrelated-histories knowing that our source can be a local path