Search code examples
gitgithublatexgitignoretex

How should I use .gitignore?


I'm new to Github and Git as whole. I'm working on a repository that has a lot of .tex files and mostly Matlab code. The IDE for Latex I use is Texpad and it creates a folder called .texpadtmp for auxiliary files. It looks like this:

enter image description here

If I got it right, .gitignore is all about creating a set of types of files and folders which will be explicitly ignored by Git when committing and tracking. I took to some other repos and how they created their .gitignore file and I created something that looks like this (whit the help of a GitHub template):

enter image description here

However, although I have updated my local repo and everything is in sync, the aforementioned folder is still there and all the auxiliary files are still there, still visible. Is this the expected behavior? Shouldn't it be omitted somehow and never be committed upon or tracked again? Thanks in advance.


Solution

  • The .gitignore file specifies patterns of untracked files to intentionally ignore. Once a file has been committed, it is tracked; that's why your new ignore file appears to have no effect!

    You can get more details about the usage of ignore files in the dedicated manual page (git help ignore). This manual page also hints at how to stop tracking files that are currently being tracked:

    The purpose of gitignore files is to ensure that certain files not tracked by Git remain untracked.

    To stop tracking a file that is currently tracked, use git rm --cached.