git - 无法推送到 GitHub - 一直说需要 merge

标签 git

我是 GitHub 的新手.今天我在尝试将我的代码推送到 GitHub 时遇到了一些问题。

Pushing to git@github.com:519ebayproject/519ebayproject.git
To git@github.com:519ebayproject/519ebayproject.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:519ebayproject/519ebayproject.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

我还没有在存储库中推送任何东西,那么为什么我需要 pull 一些东西?

最佳答案

This can cause the remote repository to lose commits; use it with care.

如果您不想将远程分支 merge 到您的本地分支(请参阅与 git diff 的区别),并且想要强制推送,请使用 push command with -f

git push -f origin <branch>

其中 origin 是您的 remote 的名称 repo 。

Usually, the command refuses to update a remote ref that is not an ancestor of the local ref used to overwrite it. This flag disables the check. This can cause the remote repository to lose commits; use it with care.

关于git - 无法推送到 GitHub - 一直说需要 merge ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10298291/

相关文章:

git - 在具有私有(private) repo 依赖项的 docker 容器中使用 bower

bash - 为什么 ". myscript"仅在 Windows sh.exe 的一个 Git 中返回文件未找到?

ios - 考虑制作一个开源 iOS 应用程序,我应该在我的 .gitignore 中添加什么?

git - 什么是 "stale"git 分支?

Git错误: remote unpack failed when pushing to a bare repo

linux - 检查预提交钩子(Hook) shell 脚本中的 git 状态

git - 如何从 VisualStudio.com 的 Git 分支自动部署到 Azure?

git - 如何比较git中两个非顺序提交的代码?

Git:使用 rebase 应用主题分支(不 merge )

git - 从 bundle 备份恢复 git 存储库