简体   繁体   English

Unstage已提交更改但将新文件保留在索引中

[英]Unstage committed changes but keep new files in index

I want to split the last commit in two, so I use git reset HEAD~1 , but then it loses track of the new files that were added by the commit (which were not tracked before), and I have to carefully add them back one by one. 我想将最后一次提交拆分为两个,所以我使用git reset HEAD~1 ,但是它失去了跟踪由提交添加的新文件(之前没有跟踪过),我必须小心地将它们添加回来逐一。 I often have other untracked files lying around waiting to be committed later, so this is annoying. 我经常有其他未跟踪的文件等待稍后提交,所以这很烦人。

What I would like is a way to reset but keep the files added by the commit as empty, as if they had been added with git add --intent-to-add (ie git add -N ). 我想要的是一种reset的方法,但保持提交添加的文件为空,就好像它们已经添加了git add --intent-to-add (即git add -N )。

After reading the doc more attentively, I found the answer. 在仔细阅读文档后,我找到了答案。

This does exactly what I want: git reset --mixed -N HEAD~1 这正是我想要的: git reset --mixed -N HEAD~1

也许我不太了解,但是不是那个git reset --soft

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

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