如何更改过去的提交以包含错过的文件? [英] How to change past commit to include a missed file?
本文介绍了如何更改过去的提交以包含错过的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我犯了一个变更,并忘记将文件添加到更改集。在其他提交之后,我意识到文件现在从 HEAD ^ 4
提交中丢失。
如何重写以前的承诺包括缺少的文件?
解决方案
使用 git rebase --interactive HEAD〜4
并为要修改的提交设置 edit
选项。 请记住,应该而不是修改以这种方式推送到远程存储库的提交。在这种情况下,最好添加一个缺失文件的新提交。
I have committed a change and forgot to add a file to the change set. After other commits, I realized the file is now missing from a HEAD^4
commit.
How do I rewrite a previous commit to include the missing file?
解决方案
Use git rebase --interactive HEAD~4
and set edit
option for the commit you'd like to amend.
Remember that you should not modify commits pushed to the remote repository this way. It's better to add a new commit with missing file in that case.
这篇关于如何更改过去的提交以包含错过的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文