简体   繁体   English

如何解决“由于当前分支的尖端落后而导致更新被拒绝”?

[英]How can I solve “Updates were rejected because the tip of your current branch is behind”?

I want to push to github.我想推到 github。 I am using SourceTree.我正在使用 SourceTree。

When I push, I get an error like this:当我推动时,我收到这样的错误:

错误

How can I solve this problem?我怎么解决这个问题?

The graph on SourceTree is like this: SourceTree 上的图形是这样的:

图形

If I pull, it displays an error too like this:如果我拉,它也会显示一个错误,如下所示:

拉

In your screen shot you can see 3 commits, two commits are connected, test and remove test, but then your newest commit does not have a parent, hence no related histories.在您的屏幕截图中,您可以看到 3 个提交,两个提交已连接,测试和删除测试,但是您的最新提交没有父级,因此没有相关历史记录。

Option 1 ( origin/master has no useful code)选项 1( origin/master没有有用的代码)

Judging by the commit messages, you have an empty repo before your latest commit.从提交消息来看,您在最近一次提交之前有一个空的仓库。 In this situation, I would force replace what is on remote by doing git push -f .在这种情况下,我会通过执行git push -f来强制替换远程设备上的内容。

Please note this will delete the commits labeled test and remove test .请注意,这将删除标记为test的提交并remove test

Option 2 ( Keep origin/master )选项 2(保留origin/master

Use git cherry-pick those commits into your local master.使用git cherry-pick到您的本地主机中。 Always do this oldest to newest.始终从最旧到最新执行此操作。

git cherry-pick <commit hash>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 更新被拒绝,因为您当前分支的提示落后 - 但为什么? - Updates were rejected because the tip of your current branch is behind - but why? 更新被拒绝,因为您当前分支的尖端在后面...不正确 - Updates were rejected, because the tip of your current branch is behind… Not true git:“更新被拒绝,因为您当前分支的尖端落后..”但是如何查看差异? - git: "Updates were rejected because the tip of your current branch is behind.." but how to see differences? 如何解决 git 错误:“更新被拒绝,因为您当前分支的提示落后了” - How to resolve git error: "Updates were rejected because the tip of your current branch is behind" Git 更新被拒绝,因为您当前分支(主)的尖端在后面但是分支是最新的? - Git Updates were rejected because the tip of your current branch (main) is behind BUT branch is up to date? 在&#39;git filter-branch`之后无法推送到Heroku:更新被拒绝,因为当前分支的提示落后了 - Can't push to Heroku after a `git filter-branch`: Updates were rejected because the tip of your current branch is behind 如何解决git错误:重命名远程分支时“更新被拒绝,因为当前分支的提示落后” - How to resolve git error: “Updates were rejected because the tip of your current branch is behind” when renaming a remote branch GitLab 更新被拒绝,因为您当前分支的尖端落后于其远程对应分支 - GitLab Updates were rejected because the tip of your current branch is behind its remote counterpart Gradle-release-plugin 更新被拒绝,因为您当前分支的尖端落后 - Gradle-release-plugin Updates were rejected because the tip of your current branch is behind 源树推送:提示:更新被拒绝,因为当前分支的尖端落后 - Source Tree Push : hint: Updates were rejected because the tip of your current branch is behind
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM