Proper way to remove unwanted files with git filter-branch without git rm failing

前端 未结 4 1129
迷失自我
迷失自我 2020-12-10 18:58

I have a project of an SNMP agent where the related MIB files (*.smiv2 files) were developed along with it, but now I want them in a separate git repository.

In orde

相关标签:
4条回答
  • 2020-12-10 19:11

    An -I switch can also be used.

    some command | xargs -I % rm % 
    
    0 讨论(0)
  • 2020-12-10 19:19

    Full Answer, for future reference

    git filter-branch --prune-empty --index-filter 'git ls-files | \
    grep -v ".smiv2$" | xargs git rm --cached --ignore-unmatch DoesNotExistInMyProject'
    
    0 讨论(0)
  • 2020-12-10 19:24

    The simplest solution would be to add a dummy argument to git rm so that it always has at least one file parameter.

    E.g.

    ... | xargs git rm --cached --ignore-unmatch DoesNotExistInMyProject
    
    0 讨论(0)
  • 2020-12-10 19:26

    xargs's -r|--no-run-if-empty flag might be cleaner:

    ... | xargs--no-run-if-emptygit rm --cached --ignore-unmatched

    0 讨论(0)
提交回复
热议问题