rsync exclude according to .gitignore & .hgignore & svn:ignore like --filter=:C

后端 未结 13 2797
没有蜡笔的小新
没有蜡笔的小新 2020-12-22 17:22

Rsync includes a nifty option --cvs-exclude to “ignore files in the same way CVS does”, but CVS has been obsolete for years. Is there any way to make it also ex

13条回答
  •  温柔的废话
    2020-12-22 17:57

    Instead of creating exclude filters, you can use git ls-files to select each file to rsync:

    #!/usr/bin/env bash
    
    if [[ ! $# -eq 2 ]] ; then
        echo "Usage: $(basename $0)  "
        exit 1
    fi
    
    cd $1
    versioned=$(git ls-files --exclude-standard)
    rsync --verbose --links --times --relative --protect-args ${versioned} $2
    

    This works even though git ls-files returns newline separated paths. Probably won't work if you have versioned files with spaces in the filenames.

提交回复
热议问题