+1

Remove files incompatible with the current .gitignore

David Rodrigues 7 years ago updated by Paul Ewers 1 year ago 4

If you create a file like "abc.txt", commit it, then create a gitignore to ignore that file, this file will keep being part of the repository. So a solution like "removed ignored files" should be great.


It could be done automatically, like an suggestion to user just remove a new ignored file from repository, or as a tool option (via menu).


It basically do that:


git rm -r --cached . 
git add .


https://stackoverflow.com/a/19095988/755393

You may try following in SmartGit:

  • show files recursively
  • remove all tracked files but keep them physically available
  • commit them
  • add all "untracked" files
  • amend-commit them

Now the latest commit should only contain files that were considered ignored. Alternatively, you may create a tiny script that invokes your above mentioned commands and add that to the Tools section in the preferences.

+3

The git command seems be more pratical hehe. But I mean, it could be available directly from Smartgit, without need do all manually (for both: run commands or then your method). It will help with repository cleanup.

I agree, I think the following is easier, and probably should be part of a smart git command
(the auto commit could be an option):

git rm -r --cached . 
git add .
git commit -am "Remove ignored files and resubmitting files"

As an additional step, I think you could automatically check in the background whenever a `.gitignore` changes, whether or not there would be any changes and potentially ask the user.

+1 This feels like a missing feature and would be great to see in a future version of SmartGit!