关于github:git push被拒绝,Pull Failed:致命:拒绝合并不相关的历史记录

git push rejected, Pull Failed: fatal: refusing to merge unrelated histories

本问题已经有最佳答案,请猛点这里访问。

我在Github控制台上创建了新的repo。
在Android Studio中,承诺并尝试推到远程,推被拒绝。

在Studio中,我可以成功地与Github建立连接。

尝试使用Android Studio进行Git Pull,获得:< BR>

1
Git Pull Failed: fatal: refusing to merge unrelated histories

即使在Git-Bash中也得到了:

1
2
3
4
5
6
7
8
9
>git push origin master<br/>
To https://github.com/XXXX.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/XXX.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.


1
In Android Studio,

转到master,mater-->rebase on-->你会得到:

1
Rebase Successful: Rebased master on origin/master

然后使用Android Studio进行推送。

enter image description here