[英]How to revert a unpushed git commit
I am using Idea IntelliJ Community Edition 2016 and committed a change to GIT.我正在使用 Idea IntelliJ Community Edition 2016 并提交了对 GIT 的更改。 But I have not pushed it.但我没有推它。 Now when I see my push queue I can see it in the queue.现在,当我看到我的推送队列时,我可以在队列中看到它。 I tried RESET HEAD option
but it did not work.我尝试了RESET HEAD option
但没有用。 I want to delete that commit.我想删除那个提交。 How can I do it in Intellij?我怎样才能在 Intellij 中做到这一点?
In the latest version, you simply go to version control
, right click the commit and select Undo Commit
.在最新版本中,您只需转到version control
,右键单击提交并选择Undo Commit
。 This will put the changes back into a change list (so you can edit if needed) and remove the commit.这会将更改放回更改列表(以便您可以根据需要进行编辑)并删除提交。 You can remove the change list / revert the changes if you want them gone completely.如果您希望它们完全消失,您可以删除更改列表/还原更改。
Using the Reset HEAD
option should work too, just make sure to select a correct target and set an appropriate reset type ( Mixed
if you want to keep the changes, Hard
if you want the changes gone too).使用Reset HEAD
选项也应该有效,只需确保选择正确的目标并设置适当的重置类型(如果您想保留更改,则为Mixed
,如果您希望更改也消失,则为Hard
)。 To make it easier to find the target, you can find a Reset Current Branch to Here
option when right clicking a commit in version control
.为了更轻松地找到目标,您可以在version control
右键单击提交时找到“将Reset Current Branch to Here
选项。
In that VCS > Git > Reset HEAD
dialog from IntelliJ, you wanted to:在 IntelliJ 的VCS > Git > Reset HEAD
对话框中,您希望:
Soft
as the Reset Type
(to keep the changes of the undone commit)选择Soft
作为Reset Type
(以保留未完成提交的更改)HEAD^
as the commit (to point 1 commit back in the history of your branch)使用HEAD^
作为提交(指向分支历史记录中的 1 个提交) That is equivalent to the following git command: git reset --soft HEAD^
这相当于下面的 git 命令: git reset --soft HEAD^
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.