git filter-branch —force —index-filter ‘git rm —cached —ignore-unmatch ${PATH_of_file}‘ —prune-empty —tag-name-filter cat — —all

    eg.

    1. 取消对文件追踪

      1. git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch concurrency/02_lambda_thread' --prune-empty --tag-name-filter cat -- --all
    2. 取消对文件夹的追踪(加-r)

      1. git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch LinuxTinySTL/build -r' --prune-empty --tag-name-filter cat -- --all