Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to use .gitignore file to ignore .log files [duplicate]

I am writing in LaTeX and when you save a file in .tex it generate files that I don't want git to track.

The .tex file will make a .log, .aux, .synctex.gz file. I have successfully ignored the .aux and the .synctex.gz with this:

.DS_Store
*.log
*.aux
*.synctex.gz

But the log file is still tracked. When I do a git add * it says:

modified:   assets/latex/array/array.log
modified:   assets/latex/array/array.pdf
modified:   assets/latex/template.log
modified:   assets/latex/template.pdf
modified:   assets/latex/template.tex

Also, I have tried this:

.DS_Store
assets/latex/array/array.aux
assets/latex/array/array.log
assets/latex/array/array.synctex.gz

assets/latex/else/else.aux
assets/latex/else/else.log
assets/latex/else/else.synctex.gz

assets/latex/elseif/elseif.aux
assets/latex/elseif/elseif.log
assets/latex/elseif/elseif.synctex.gz

assets/latex/for-loop/forloop.aux
assets/latex/for-loop/forloop.log
assets/latex/for-loop/forloop.synctex.gz

assets/latex/if/if.aux
assets/latex/if/if.log
assets/latex/if/if.synctex.gz

assets/latex/switch/switch.aux
assets/latex/switch/switch.log
assets/latex/switch/switch.synctex.gz

assets/latex/var/var.aux
assets/latex/var/var.log
assets/latex/var/var.synctex.gz

assets/latex/template.aux
assets/latex/template.log
assets/latex/template.synctex.gz

This also doesn't work.

like image 459
heybit Avatar asked Jan 03 '17 21:01

heybit


People also ask

Are Gitignore files cloned?

gitignore is created, the file will still be part of the repository and therefore cloned. Even that's an overstatement: an entry in a . gitignore file is only considered when some file is untracked. A committed file, as (because) it is being checked out, automatically becomes tracked.

How do I ignore already added files in Git?

Git can only ignore files that are untracked - files that haven't been committed to the repository, yet. That's why, when you create a new repository, you should also create a . gitignore file with all the file patterns you want to ignore.

How do I exclude a file from Gitignore?

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.

Why is my .gitignore file not working?

a. The most straightforward way to rectify this issue will be to delete all the files that are supposed to be ignored from your repository and make a commit. This will cause the files to become untracked by Git. After the files are deleted, if they are properly listed in . gitignore , they should no longer be tracked.


1 Answers

You can use **/*.log, where the double-star means to apply it recursively, so it will match every subdirectory.

like image 82
Jared Grubb Avatar answered Sep 27 '22 19:09

Jared Grubb