[英]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 个提交,两个提交已连接,测试和删除测试,但是您的最新提交没有父级,因此没有相关历史记录。
origin/master
has no useful code)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
。
origin/master
)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.