【问题标题】:How to git rm all deleted files from repo, excluding others如何 git rm 从 repo 中删除所有文件,不包括其他文件
【发布时间】:2014-10-27 05:30:48
【问题描述】:

我已经使用这篇帖子 Removing multiple files from a Git repo that have already been deleted from disk 来弄清楚如何使用 git rm 一次删除多个文件。

现在,我想这样做,不包括一个目录。我试过这个:

git rm $(git ls-files --deleted --exclude='sites/all/modules/imagecache_actions/')

但它没有用。我是否滥用了排除标签?

【问题讨论】:

  • 如果唯一的更改是删除,只需使用git add -u . 暂存所有更新/删除,然后使用git reset <directory> 取消暂存您想要保留的一个目录。
  • 就是这个问题,也有修改。所以,我想要一种干净的方式来排除它们

标签: git git-add git-rm


【解决方案1】:
git ls-files -d | sed '/^sites\/all\/modules\/imagecache_actions\//d' | xargs git rm

-x --exclude 选项仅适用于未跟踪的文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-03
    • 2012-05-22
    • 2023-03-09
    • 1970-01-01
    • 2018-08-27
    • 2014-12-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多