简体   繁体   English

如何撤消我在Git中的最后一次提交并隐藏这些更改呢?

[英]How can I undo my last commit in Git and stash those changes instead?

I have a branch called feat-a and I essentially want to "undo" my last local commit and just have those files staged. 我有一个名为feat-a的分支,我基本上想要“撤消”我的上一次本地提交,只是让这些文件上演。 Then when they are all staged I want to stash those changes. 然后,当他们全部上演时,我想隐藏这些变化。

Now what I'm doing does sound a bit backwards, but the cause of this issue was a force push on master to re-write some commit authors, so doing a merge or rebase of master onto/into feat-a just completely breaks with a ton of conflicts even though master and feat-a are only off by one commit. 现在我正在做的事听起来有点倒退,但是这个问题的原因是强制主人重新写一些提交作者,所以做一个合并或重组主人进入/进入feat-a完全打破尽管master和feat-a只是一次提交,但仍有大量的冲突。

I have read through a similar question here: How to stash my previous commit? 我在这里读过一个类似的问题: 如何存储我以前的提交?

But it isn't necessarily what I want to do. 但这不一定是我想要做的。 I just want to unstage and stash my last direct commit, versus what that user wanted (ie pull a commit out from between other commits). 我只是想取消暂停和隐藏我的最后一次直接提交,而不是用户想要的东西(即从其他提交之间拉出提交)。

git reset --soft HEAD~1
git stash save "Saving instead" # or something like that

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM