I have faced similar problem for one of the files in my spring boot project as it was not added in the project and somehow in the git commit too. It was not showing in the main branch of the git where I have merged my changes earlier so,
All I did is created another branch from the main into my local
then renamed that file into fileName_Temp.java which was showing orange in local as it was already there
then created new java file fileName.java and copy pasted everything from temp(fileName_Temp.java) to current file(fileName.java)
then committed my changes again and merged this new branch after commit into main branch
This solved my problem.