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.
If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a . gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.
Configuring ignored files for a single repository You can create a . gitignore file in your repository's root directory to tell Git which files and directories to ignore when you make a commit. To share the ignore rules with other users who clone the repository, commit the . gitignore file in to your repository.
File locking is enabled by default in LibreOffice. On a network that uses the Network File System protocol (NFS), the locking daemon for NFS clients must be active. To disable file locking, edit the soffice script and change the line “export SAL_ENABLE_FILE_LOCKING” to “# export SAL_ENABLE_FILE_LOCKING”.
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.
Answer (as you discovered in your comments): adding *.~lock*
inside the .gitignore
file works just fine.
Also, if using Git for Windows, be sure to name your .gitignore
file .gitignore
, NOT .gitignore.txt
, which is what Windows tries to force it to be if renaming or creating the file with Windows Explorer. To do this, save it using a text editor rather than trying to rename it in Windows Explorer (see more on this here).
If you accidentally have the .txt
extension at the end it will NOT work and git will NOT read the file properly as a .gitignore
file.
For more-detailed gitignore formatting notes, and to learn the syntax of how to specify files and folders to be ignored, see my comments and examples in my .gitignore
file in my eRCaGuy_dotfiles repo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With