【问题标题】:Git push is not workingGit推送不起作用
【发布时间】:2017-06-21 15:35:39
【问题描述】:

我正在尝试在 github 上推送本地 repo,但 git push 对我不起作用,以下是错误

git push https://github.com/MandarSant/Mandars_First_Repo.git master
To https://github.com/MandarSant/Mandars_First_Repo.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/MandarSant/Mandars_First_Repo.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 push
  • git pull origin master --rebase
  • 你有没有阅读错误信息?

标签: git github push


【解决方案1】:

就像错误消息所说的那样,您尝试推送到的存储库已被其他人修改。为了让您能够推送到存储库,您应该拥有最新的更改。

所以你要做的是确保你告诉 git,你知道其他人所做的更改。这样做的方法是做一个git pull。完成此操作后,您应该能够推送到存储库。

【讨论】:

    【解决方案2】:

    发生的事情是其他人已推送到 master 而您在本地没有这些更改

    从 master 中拉取它们的更改与您的合并,然后您可以推送

    【讨论】:

      【解决方案3】:

      如果每次有人没有阅读错误消息时我都有一毛钱......

      你需要先git pullgit push

      【讨论】:

      【解决方案4】:

      在将任何内容推送到 git 存储库之前,您需要执行 git pull 命令。 如果有时可能会通知您某些文件将被合并覆盖,在这种情况下,您必须存储您的更改或将这些文件复制到另一个地方,然后必须恢复更改,然后在拉取后应用您的更改。

      【讨论】:

        猜你喜欢
        • 2013-08-21
        • 2020-03-27
        • 2018-02-28
        • 2011-03-12
        • 2016-12-20
        • 2015-05-28
        • 2015-03-23
        • 2014-10-04
        • 2015-11-07
        相关资源
        最近更新 更多