删除文件作为提交的一部分
假设我有一个文件系统,其中包括:
file1.java
file2.java
file3.java
file4.java
我刚刚完成了一个具有 betterfile.java
的提交,该提交应该替换 file
1,2,3 和 4。所以我我即将提交 betterfile.java
但现在我对其他文件没有用处。那么我如何从下一次提交中删除它们。如何从我即将执行的提交中删除所有其他文件(file1
、file2
等),但仍保留它们的历史记录?
Say I have a file system that includes:
file1.java
file2.java
file3.java
file4.java
And I just finished a commit that has betterfile.java
that is supposed to replace file
1,2,3 and 4. So I am about to commit betterfile.java
and now I have no use for the other files. So how do I delete them from the next commit. How could I remove all of the other files (file1
, file2
, etc.) from the commit I'm about to do, but still keep them historically?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
通过 shell、windows 或其他方式添加和删除文件,将文件更改为您想要的目录结构。然后:
这会暂存所有更改,包括删除、添加和修改。
现在就可以走了。
Change the files to what you want the directory structure to look like by add and deleting files via shell, windows or whatever. Then:
This stages all changes including deletes, additions and modifications.
and you're good to go.
如果您使用 TortoiseGit 这样的工具,那么只需删除不需要的文件,替换为新文件并正常提交即可。文件将被标记为“已删除”,新文件将被标记为“已添加”。
If you're using a tool like TortoiseGit then just delete the files you don't want, replace with the new file and commit as normal. The files will be marked as 'deleted' and the new file as 'added'.