I have a GitHub repo where I keep mainly .tex files, with Makefiles that compile all of the files to create .pdfs. On this repo, the .gitignore file serves to ignore some compilation files related to this, most notably the .pdfs themselves. Now I also have some files that aren't the result of compiling the .tex files, and should therefore not be ignored by git. I recently added some code (using the minted package) in my .tex files that creates compilation files of two certain types, namely .pygstyle and .pygtex. These files are files I don't want to keep in the repo, hence I added them to my .gitignore--after already adding them in a previous commit :(.
I'd like to find the commands I'd have to type in order to rebase this branch in a way that doesn't remove all files in the .gitignore from source control, seen as there are some .pdfs that I'd like to keep, but the compilation files I mentioned above should be ignored.
I tried rebasing the normal way, only to find out about those lost files that couldn't be ignored; ever since, I've been aimlessly rebasing onto new branches, with little to no success.
Ideally, there would be a way to retroactively apply the .gitignore file to the commits introducing the "naughty files", without removing other files that were manually added to bypass the .gitignore.
I thought about not using rebase (for example by simply applying the .gitignore to a subset of all the files), but I'd like to keep it clean and use git rebase instead.