毎回忘れるので残します
.gitignoreテンプレ
.gitignore
# Xcode (from gitignore.io)
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
# CocoaPod
Pods/*
# others
*.swp
!.gitkeep
.DS_Store
反映させるコマンド
.gitignore作る前にプッシュをするなどして、キャッシュにインデックスが残っている場合、下記のコマンドを実行する必要があります。
git rm -r --cached .
git add .
キャッシュ全部消してまた新しく管理対象を作り直すイメージですね
2022/12/29追記
例えば、dataフォルダを無視したいときはこんな感じでやる
/data/*