Github中的快进错误

时间:2018-01-29 09:09:40

标签: git github fast-forward

作为我正在做的在线课程的一部分,我是git的新手。

目前正在做一个教程,当我第一次推送到master时收到以下错误消息:

$ git push -u origin master
To https://github.com/-/myappsample.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/-/myappsample.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.

我尝试了一个git pull,但这也行不通:

$ git pull https://github.com/-/myappsample.git master
From https://github.com/-/myappsample
 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories

这是一个全新的Github帐户,带有一个新的/空的回购。

关于出了什么问题以及如何解决这个问题的想法?

感谢

1 个答案:

答案 0 :(得分:1)

当远程存储库已更新且本地尝试将其新更改推送到远程而不更新其内容时,会发生上述问题。

问题可以通过拉动来解决。您可以尝试以下任何一项或全部:

  1. git pull --all
  2. git pull origin< your_branch_name>
  3. git pull --rebase
  4. 最后一个选项是最好的选项,因为它会尝试针对远程重新设置您的repo以防止额外的合并提交。

    这里可以找到一个很好的例子github resolve fast-forward errors。如果在拉动之后,您会收到错误/冲突,您还需要解决它们。