Sourcetree-撤消未推送的提交 [英] Sourcetree - undo unpushed commits

查看:2774
本文介绍了Sourcetree-撤消未推送的提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Sourcetree for Windows用于git存储库,并希望撤消未推送的提交.

I am using Sourcetree for Windows for a git-repository and would like to undo an unpushed commit.

有可能吗?如果我执行还原提交",它将创建第二个提交以还原第一个提交,但是我不希望第一个提交完全出现在我的源代码管理中.

Is that possible? If I do "revert commit", it creates a second commit which reverts the first commit, but I don't want the first commit to appear at all in my source control.

我还可以删除本地存储库,然后在没有本地提交的情况下再次将其拉出,但是也许还有另一种方法?

I could also delete my local repository and pull it again without my local commit, but maybe there's another way?

推荐答案

  1. 右键单击要重置为的提交(而不是要删除的提交!)
  2. 选择将主服务器重置为此提交"
  3. 选择软"重置.

软重置将保留您的本地更改.

A soft reset will keep your local changes.

来源: https://answer.atlassian.com/questions/153791/how-should-i-remove-push-commit-from-sourcetree

修改

关于git revert:此命令创建一个新的提交,它将撤消其他提交.例如.如果您有添加新文件的提交,则可以使用git revert进行提交,以删除新文件.

About git revert: This command creates a new commit which will undo other commits. E.g. if you have a commit which adds a new file, git revert could be used to make a commit which will delete the new file.

关于应用软重置:假定您具有AE(A---B---C---D---E)的提交,并且您想删除最后一次提交(E).然后,您可以进行软重置以提交 D .通过软复位,提交E将从git中删除,但将保留本地更改. git reset文档中有更多示例.

About applying a soft reset: Assume you have the commits A to E (A---B---C---D---E) and you like to delete the last commit (E). Then you can do a soft reset to commit D. With a soft reset commit E will be deleted from git but the local changes will be kept. There are more examples in the git reset documentation.

这篇关于Sourcetree-撤消未推送的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆