gitgitignorelibreoffice

How can I tell git to ignore LibreOffice lock files?


I have a git repo which contains some XSLX files. I edit them with LibreOffice every once in a while. Sometimes LibreOffice won't remove the lock files ( ./folder/.~lock.filename.xslx#). This causes those files to be liested as new on every git status.

I would like git to ignore them. I tried the following in .gitignore but doesn't seem to work:

*.~lock*
.~lock*
*/.~lock*

Any ideas?

UPDATE

Also tried:

.~lock.*#

As seen in http://lists.freedesktop.org/archives/libreoffice-commits/2012-December/040253.html with no success.


Solution

  • To test patterns for .gitignore,

    git ls-files -iocx '.~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.