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

查看:248
本文介绍了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. 选择将 master 重置为此提交"
  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.

关于应用软重置:假设您将 A 提交到 E (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天全站免登陆