I used to have this same problem all the time.
First, close Xcode. This will only continue to generate the xcuserstate changes that will keep coming up. Open up your project folder, we need to get the userstate outta there. If you right click your .xcodeproj file, select Show Package Contents. This will allow you to see everything hiding in there. You can delete the .xcuserdata file there. This may lose your Xcode state, like which folders you had opened, tabs, etc. But it shouldn't hurt your project in any way. It will just create another one next time you open Xcode.
Next, open up Terminal. This is the best way to handle this issue. Make sure you are in the directory of your project inside terminal. If you aren't sure, type cd
and drag and drop the project folder into Terminal to load the location name.
rm .DS_Store
This will delete the hidden folder file Mac OS creates. Don't worry about it. Close the project folder if you haven't already, or it will just create another one.
Hopefully if you've gotten this far, you can run git status
in terminal on this current setup and should see a message showing just the 1 file left to commit. The pbxproj file. If so, great!
git add project.pbxproj
git commit -m "Put some commit message for this file"
This should add your project file and commit it git and clear things up. A git status should show your repo is free and clear of all your untracked and uncommitted files.
With any luck, when you fire up Xcode again and those files get created, your gitignore file should kick in and ignore them for future commits. This used to happen to me a lot when I first started with git. I finally learned to check the ignore file in first before adding any Xcode source files. Hope this helps.