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.
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.
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.
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.
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.
You can use **/*.log
, where the double-star means to apply it recursively, so it will match every subdirectory.
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