如何从提交中删除行并将其放回工作目录? [英] How to remove line from commit and put back her to working directory?
问题描述
我在工作目录中有一些将来提交的数据,但是在某些提交中出错,因为它包含必须在将来提交中的一行.那么如何从提交中删除该行并将其返回到工作目录以进行下一次提交?
I have data in the working directory for several future commits but i made mistake in some commit because it contains a line which must be in the future commit. So how can i delete that line from commit and return it to the working directory for next commit?
推荐答案
首先:
git rebase -i target_commit_hash^
并编辑提交,取消暂存所需行(git reset HEAD -p
)并修改提交.然后使用这一行来暂存文件,并保存在单独的提交中.之后,继续进行变基.
and edit the commit, unstage wanted line (git reset HEAD -p
) and amend the commit. Then stage the file with this one line and save in a separate commit. After that continue the rebase.
然后重新设置基准:
git rebase -i target_commit_hash^
并将提交内容一行移到树的顶部.
and move the commit with your one line to the top of the tree.
然后:
git reset HEAD^
这将删除一行中的临时提交,并使该行变为未登台.
this will remove the temporary commit with your one line and make this line as unstaged.
这篇关于如何从提交中删除行并将其放回工作目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!