To test patterns for .gitignore
,
git ls-files -ix '.~lock*'
To see if any cached aka staged aka tracked aka added files match ignore patterns (and so may have been added in error),
git ls-files -ic --exclude-standard
As @NevikRehnel pointed out, git won't ignore tracked files. To un-track a file,
git rm --cached path/to/it
which will take it out of the next commit, but the only way to take a file out of earlier history is a rewrite with e.g. git commit --amend
if it was just the last commit, git rebase -i
if you've got only a few to do or git filter-branch
for bulk work. None of those actually alters the old history, they add new history and switch any current branch to refer to it. The old history is still there, and no other refs are moved.