I had the same problem all the time.
Close Xcode first. This will continue to generate xcuserstate changes that will continue. Open your project folder, we need to get user status from it. If you right-click on the .xcodeproj file, select Show Package Contents. This will allow you to see everything that is hiding there. You can delete the .xcuserdata file. This may lose your Xcode state, for example, which folders you opened, tabs, etc. But this in no case should harm your project. It will just create another next time you open Xcode.
Then open a terminal. This is the best way to deal with this problem. Make sure that you are in the directory of your project inside the terminal. If you're not sure, type cd and drag the project folder into the terminal to load the location name.
rm .DS_Store
This will delete the hidden folder file created by Mac OS. Do not worry about it. Close the project folder if you do not already have one, or just create another one.
I hope that if you get to this, you can run git status in the terminal in this current setting and see a message showing only 1 file left to commit. Pbxproj file. If so, great!
git add project.pbxproj git commit -m "Put some commit message for this file"
This should add the project file and pass it to git and clear everything. The git status should indicate that your repo is free and free of all your unsolicited and uncommitted files.
If you're lucky when you run Xcode again and the files are created, your gitignore file should run and ignore them for future commits. This used to happen to me when I first started with git. I finally learned how to check the ignore file first before adding the Xcode source files. Hope this helps.
source share