My git repo includes MS Office files (Word, PPT, & Excel), each time I open one of them a temporary file starting with ~$<file-name>
is created.
I tried adding */~$*
to the .gitignore
file, but it still does not work; the temporary file still pops up in the change list shows that there are untracked changes all the time. I had to close all office files to know that my repo is up-to-date.
How to solve this problem? Is there a special syntax for .gitignore
for such files?
Git can specify which files or parts of your project should be ignored by Git using a .gitignore file. Git will not track files and folders specified in .gitignore. However, the .gitignore file itself IS tracked by Git.
These kinds of ignores are specified in the .git/info/exclude file. It works the same way as .gitignore but are not shown to anyone else. In .gitignore add a line to ignore all .temp files:
Temporary files from your development environment, test outputs, and logs are all examples of files that you create but aren't part of your codebase. Customize which files Git tracks through the gitignore feature.
If a file is already tracked by Git, adding that file to your .gitignore is not enough to ignore changes to the file. You also need to remove the information about the file from Git's index: These steps will not delete the file from your system. They just tell Git to ignore future updates to the file.
To ignore any file starting with ~$
, use the pattern:
~$*
Nothing more is needed.
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