我正在跑步
git status
我有大量的已删除文件,需要使用
删除它们git rm
问题是我需要在一个命令中将它们全部删除,并且列表太长,无法全部选择。有没有一种方法可以自动同步git,以便将其全部永久删除?下面是示例输出日志:
deleted: everest-web/rails/railties/test/generators/system_test_generator_test.rb
deleted: everest-web/rails/railties/test/generators/task_generator_test.rb
deleted: everest-web/rails/railties/test/generators/test_runner_in_engine_test.rb
deleted: everest-web/rails/railties/test/generators_test.rb
deleted: everest-web/rails/railties/test/initializable_test.rb
deleted: everest-web/rails/railties/test/isolation/abstract_unit.rb
deleted: everest-web/rails/railties/test/json_params_parsing_test.rb
deleted: everest-web/rails/railties/test/minitest/rails_plugin_test.rb
deleted: everest-web/rails/railties/test/path_generation_test.rb
deleted: everest-web/rails/railties/test/paths_test.rb
deleted: everest-web/rails/railties/test/rack_logger_test.rb
deleted: everest-web/rails/railties/test/rails_info_controller_test.rb
deleted: everest-web/rails/railties/test/rails_info_test.rb
deleted: everest-web/rails/railties/test/railties/engine_test.rb
deleted: everest-web/rails/railties/test/railties/generators_test.rb
deleted: everest-web/rails/railties/test/railties/mounted_engine_test.rb
deleted: everest-web/rails/railties/test/railties/railtie_test.rb
deleted: everest-web/rails/railties/test/secrets_test.rb
deleted: everest-web/rails/railties/test/test_unit/reporter_test.rb
deleted: everest-web/rails/railties/test/version_test.rb
deleted: everest-web/rails/tasks/release.rb
deleted: everest-web/rails/tasks/release_announcement_draft.erb
deleted: everest-web/rails/tools/README.md
deleted: everest-web/rails/tools/console
deleted: everest-web/rails/tools/line_statistics
deleted: everest-web/rails/tools/profile
deleted: everest-web/rails/tools/test.rb
deleted: everest-web/rails/version.rb
答案 0 :(得分:2)
如果要先删除当前目录中的所有文件
git add .
然后您需要删除所有需要运行的文件
git rm -f *
git status
在运行上述命令时,您应该位于工作目录(当前目录)中
答案 1 :(得分:0)
对于Git 1.x
$ git add -u
这告诉git自动登台跟踪的文件-包括删除以前跟踪的文件。
对于Git 2.0
要准备整个工作树:
$ git add -u :/
仅暂存当前路径:
$ git add -u .
ref:here
答案 2 :(得分:0)
来自git手册页:
如果您真正想要做的就是从索引中删除工作树中不再存在的文件(可能是因为您的工作树很脏,因此您无法使用git commit -a),请使用以下命令:
git diff --name-only --diff-filter=D -z | xargs -0 git rm --cached