Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make git ignore temporary files created by MS Office (starting with ~$)

Tags:

git

gitignore

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?

like image 402
Ébe Isaac Avatar asked May 15 '20 04:05

Ébe Isaac


People also ask

What is the use of Git ignore in Git?

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.

How to ignore all temp files in a git repository?

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:

What are temporary files in Git?

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.

What happens if I add a file to gitignore?

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.


1 Answers

To ignore any file starting with ~$, use the pattern:

~$*

Nothing more is needed.

like image 146
1615903 Avatar answered Jan 22 '23 15:01

1615903