我是Git & GitHub新手,
我有一个名为HackerRank的本地存储库,还有一个远程存储库https://github.com/xxx/HackerRank.git
现在,我想将本地存储库推送到远程存储库。
我使用了以下命令
git remote add hacker https://github.com/xxx/HackerRank.git
git push hacker master
它抛出了这个错误
To https://github.com/xxx/HackerRank.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/xxx/HackerRank.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
因此,现在我尝试使用以下命令从我的远程存储库中拉出
git pull hacker master
From https://github.com/xxx/HackerRank
* branch master -> FETCH_HEAD
* [new branch] master -> hacker/master
fatal: refusing to merge unrelated histories
现在,我尝试使用以下命令进行提取
$ git fetch hacker
From https://github.com/xxx/HackerRank
* [new branch] master -> hacker/master
现在,我尝试使用以下命令进行合并
$ git merge hacker/master
fatal: refusing to merge unrelated histories
请推荐我。
发布于 2016-08-29 13:54:13
您可以尝试在远程主分支上重新设置本地分支的基础,并推送它:git pull --rebase hacker master
您还可以尝试使用git merge --squash hacker/master
进行压缩合并
https://stackoverflow.com/questions/39207797
复制相似问题