首页 > 解决方案 > 如何使用 sourceTree 推送?

问题描述

我正在用sourceTree管理Unity的项目(ver 4.6.3)我只是想回到之前的提交,右键选择“Reset current branch to this commit”,在使用模式下选择“Hard”,然后放回去到上一个提交。在那之后,我试图推动,但我没有推动。对不起,我当时忘记接受错误了。

在那之后,我认为我无法按原样推送,所以我创建了另一个远程存储库,将我的 Unity 项目移到那里并提交了它。尽管我能够提交,但我无法推动它。当时的错误在这里

git -c diff.mnemonicprefix=false -c core.quotepath=false push -v --tags    
origin master:master
fatal: HttpRequestException encountered.
   ????v??????M????G???[??????????????B

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

是否有需要删除的文件?如果你知道答案,请告诉我。

标签: gitatlassian-sourcetree

解决方案


如果您执行 a reset --hard,您将需要强制推送以完成您的操作。

SourceTree 自 2016 年起支持它:

您首先需要在选项菜单中启用强制推送,然后您将能够在使用“安全”和“不安全”强制推送之间进行选择。
每次从推送对话框中使用 force-push 时,您都需要选中复选框,并确认对话框提示。

如果您不是一个人在该存储库上工作,请确保您已警告您的同事。
(考虑git push --force-with-lease到 SourceTree 尚不支持


推荐阅读