gpt4 book ai didi

git - 如何删除从 .git 中删除的文件?

转载 作者:太空狗 更新时间:2023-10-29 13:17:48 25 4
gpt4 key购买 nike

当我使用 mv 删除文件(或重命名)时, rm或其他一些工具,当我执行 git status 时,文件显示为已删除:

# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: ../src/main/..../myFile.java

在创建提交之前,做起来很麻烦git rm <file>对于每个文件,特别是因为终端中没有自动完成不存在的文件。

有没有更快捷的方法从 git 跟踪的文件集中删除已删除的文件?

谢谢

最佳答案

我相信 git add -u 会做你想做的事,来自文档:

-u
--update
Only match <filepattern> against already tracked files in the index
rather than the working tree. That means that it will never stage new
files, but that it will stage modified new contents of tracked files
and that it will remove files from the index if the corresponding file
in the working tree have been removed.

引用:http://git-scm.com/docs/git-add

关于git - 如何删除从 .git 中删除的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11488291/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com