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 already in the repo matching the new file.
This question is related to
git
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'
I might misunderstand, but are you trying to delete files newly ignored or do you want to ignore new modifications to these files ? In this case, the thing is working.
If you want to delete ignored files previously commited, then use
git rm –cached `git ls-files -i –exclude-standard`
git commit -m 'clean up'
Source: Stackoverflow.com