You will have to use your terminal to resolve this. Xcode (as of Xcode 9) does not support many of the features in git e.g git stash. 
Option 1 - Stage changes and commit using Xcode
Following this SO answer, try to stage all the local changes and repeat your steps with Xcode
- Open up terminal
- Navigate to project directory: cd /path/to/project
- Stage all local changes: git add .
- Open Xcode and try to commit again.
Option 2 - Stage and commit using terminal
If Option 1 did not resolve the issue, you can complete this task with terminal itself
- Open up terminal
- Navigate to project directory: cd /path/to/project
- Stash your changes (IMP): git stash save name-this-stash
- Reset code changes: git reset --hard HEAD~30
- Pull the latest state of remote: git pull origin branch-name
- Re-apply local changes: git stash apply
- Check current status: git status
- Stage changes to commit: git add file1 file2
- Commit changes: git commit -m "commit-message"
- Push changes to remote: git push origin branch-name
Hope it helps!