无法推送到GitHub - 一直说需要合并 [英] Cannot push to GitHub - keeps saying need merge
问题描述
我不熟悉 GitHub 。今天我遇到了一些问题,当我试图推动我的代码到GitHub。
I'm new to GitHub. Today I met some issue when I was trying to push my code to 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.
我还没有在存储库中推送任何东西,所以为什么我需要拉东西? p>
I have not pushed anything in the repository yet, so why do I need to pull something?
推荐答案
这会导致远程仓库丢失提交;小心使用它。
如果您不希望将远程分支合并到本地分支中(请参阅 git diff ),并且想要进行强制推送,请使用使用-f输入命令
If you do not wish to merge the remote branch into your local branch (see differences with git diff), and want to do a force push, use the push command with -f
git push -f origin <branch>
其中 origin
是您的< a href =https://www.kernel.org/pub/software/scm/git/docs/git-remote.html>远程回购。
通常情况下,该命令拒绝更新远程ref,该远程ref不是用于覆盖它的本地ref的祖先。此标志禁用检查。这会导致远程存储库丢失提交;小心使用它。
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.
这篇关于无法推送到GitHub - 一直说需要合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!