Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
478 views
in Technique[技术] by (71.8m points)

git - 无法推送到GitHub-一直说需要合并(Cannot push to GitHub - keeps saying need merge)

I'm new to GitHub . (我是GitHub的新手。) Today I met some issue when I was trying to push my code to GitHub. (今天,当我尝试将代码推送到GitHub时遇到了一个问题。)

Pushing to [email protected]:519ebayproject/519ebayproject.git
To [email protected]:519ebayproject/519ebayproject.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]: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.

I have not pushed anything in the repository yet, so why do I need to pull something? (我尚未在存储库中推送任何内容,那么为什么需要提取内容?)

  ask by user1353717 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This can cause the remote repository to lose commits; (这可能导致远程存储库丢失提交。) use it with care. (小心使用。)

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 diff的区别 ),并且想要进行强制推送,请在-f中使用push命令)

git push -f origin <branch>

where origin is the name of your remote repo. (其中origin是您的远程存储库的名称。)

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. (小心使用。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...