Below, I have mentioned both root-cause & solution of above error.
Root Cause:
It seems that the files you want to ignore are already committed into the repository. And .gitignore
doesn't actually ignore the files which are already committed into the repository.
Note that here untracked working tree files means that git is considering these files as untracked because .gitignore
file have their entries.
Solution:
You can fix this issue by following below easy steps:
- Create a new feature branch or separate branch.
- Delete the files which you actually want to ignore. (i.e. files mentioned in
.gitignore
) - Commit these deleted files & push the code.
- Now, raise the pull-request to merge this feature branch in your actual main branch.
- Now, this issue has been fixed in main branch. You won't get this issue again.