【发布时间】:2013-03-29 09:25:41
【问题描述】:
据我了解,每个 git commit 都会存储自上次提交以来对跟踪文件所做的更改。有没有办法让你从源代码中删除一个旧的提交?例如,如果你有一个文本文件
文本文件.txt
Text line one
More text line
然后你继续承诺git commit -m "Initial Commit"
然后你再次编辑 textfile.txt
文本文件.txt
Text line one
More text line
Even more lines
Just one more line
然后你继续承诺git commit -m "Added new lines 2"
然后您进行了最终编辑
文本文件.txt
Text line one
More text line
Even more lines
Just one more line
These are the last lines
In this file
并提交git commit -m "Added new lines 3"
有没有办法删除提交号 2 中的所有更改(“添加新行 2”),以便文件看起来像:
文本文件.txt
Text line one
More text line
These are the last lines
In this file
(请注意已删除的行 Even more lines 和 Just one more line 在提交 2 中进行了更改)
【问题讨论】: