Resync git repo with new .gitignore file

前端 未结 3 2201
感动是毒
感动是毒 2020-12-12 09:10

Is it possible to \"refresh\" a git repository after updating the gitignore file?

I just added more ignorations(?) to my gitignore and would like to remove stuff alr

3条回答
  •  忘掉有多难
    2020-12-12 09:28

    I know this is an old question, but gracchus's solution doesn't work if file names contain spaces. VonC's solution to file names with spaces is to not remove them utilizing --ignore-unmatch, then remove them manually, but this will not work well if there are a lot.

    Here is a solution that utilizes bash arrays to capture all files.

    # Build bash array of the file names
    while read -r file; do 
        rmlist+=( "$file" )
    done < <(git ls-files -i --exclude-standard)
    
    git rm –-cached "${rmlist[@]}"
    
    git commit -m 'ignore update'
    

提交回复
热议问题