无法将我的本地git repo推送到远程仓库

时间:2016-09-10 10:15:35

标签: git github

当我使用命令时 git push origin master 显示以下错误:

Username for 'https://github.com': amithld
To https://github.com/amithld/datasciencecoursera.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/amithld/datasciencecoursera.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.

即使我试图拉远程回购,也显示错误! 注意:我已经创建了远程仓库并使用自述文件对其进行了初始化。

请提出解决方案。

由于

1 个答案:

答案 0 :(得分:3)

仔细阅读错误消息:

  

更新被拒绝,因为您当前分支的提示落后于其远程对应

这意味着自上次同步以来,对远程分支进行了新的提交,现在Git不知道如何应用自那时以来所做的工作。您可以通过执行以下操作来解决此问题:

git pull origin master              # merge the remote into your local branch

git pull --rebase origin master     # rebase your local branch on the remote

在此之后,理想情况下应该有以下工作:

git push origin master