【发布时间】:2019-07-28 05:11:19
【问题描述】:
我有一个文件,我修改了 2 组更改:格式化和添加新功能。
我需要将它们变成 2 个提交。
- 格式更改
- 新功能A。
现在我使用了git add --patch 并上演了所有的格式化内容。所以我有:
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: FileA <-- formatting changes
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: FileA <-- Feature A
现在在提交之前,我意识到我将一个函数(几行)用于格式更改(它应该落在功能更改中)。
我现在可以以某种方式编辑要提交的更改吗?该文件很重要,我不想再次使用git add --patch。
我能想到的唯一可以省略运行 git add --patch 的解决方案是提交当前更改,然后从提交本身中删除这些行。
还有其他方法吗?
【问题讨论】:
-
我很想知道否决票背后的原因是什么,因为我发现它既有用又明确提出。当然,并不是说可能没有理由投反对票,我只是想知道。