无法将存储库文件推送到远程存储库(GitHub)

时间:2016-08-29 13:42:32

标签: git github github-for-windows

我是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

请建议我。

1 个答案:

答案 0 :(得分:0)

您可以尝试在远程主分支上重新绑定本地分支并推送它:git pull --rebase hacker master

您也可以尝试与git merge --squash hacker/master

进行压缩合并