从最后一次提交中删除文件 [英] Removing file from the last commit
本文介绍了从最后一次提交中删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从上一次提交中删除文件,但保留其他所有内容?请注意,我还没有将任何内容推送到远程存储库,因此我只需要在本地进行操作即可.
How can I remove a file from my last commit, but keep everything else? Please note that I haven't yet pushed anything to a remote repository, so I just have to do this locally.
我的工作流程:
- 编辑一些文件
- 意外创建一个名为
untitled.txt
的新文件
- 投入一切
- 通知不需要的
untitled.txt
文件 - 删除
- ???
- 从此过上幸福的生活
- Edit a few files
- Accidentally create a new file named
untitled.txt
- Commit everything
- Notice the unwanted
untitled.txt
file - Delete it
- ???
- Live happily ever after
提前谢谢!
推荐答案
You can easily change whatever you like in your last commit (messages, files, etc) with git commit --amend
.
因此,您将执行以下操作:
So you would do something like this:
git rm untitled.txt
git commit --amend
这篇关于从最后一次提交中删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文