I created a repository with two branches. The first branch contains a Unity project and a .gitignore file that generates GitHub. The other branch has latex files to create the documentation and other .gitignore file that is generated by GitHub too.
When I am working in the doc branch and I compile my latex files, they generate a main.syctex.gz file which is ignored by my .gitignore. Everything until here is ok. However, when I type git push -u origin doc and I switch the doc branch to the master branch, the file ignored (main.syctex.gz) appears in the master branch.
I know that if I type git clean -f -d I can clean the Doc folder that contains main.syctex.gz in the master branch. But, I would be grateful if someone can tell me another option to fix this problem.