GitHubからpullするときにfatal: refusing to merge unrelated historiesとエラーが出るときの対処法

Aug. 13, 2019, 3:41 a.m. edited Aug. 12, 2023, 7:50 a.m.

#GitHub  #Git 


$ git push origin master
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'ほげほげ'
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.


$ git pull origin master
warning: no common commits
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), done.
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> origin/master
fatal: refusing to merge unrelated histories


$ git pull --allow-unrelated-histories origin master


$ git push origin master