Just for testing, check (when you have the iMessage issue) the output of git config credential.helper
.
If you see osxkeychain
, try and (again for testing) to disable that helper, and see iMessage works again then.
To add more: if you are pushing to a remote repository using an HTTPS URL, then the credentials (username/password) are cached by Git using a host service (Windows Credential Manager for Windows, Keychain for Mac)
But, that might interfere with iMessage, preventing it to access to your iCloud credentials and therefore disconnecting your from iCloud.
Hence the "not delivered" error messages.
As a test, deactivating the Git credential caching setting can help validate that potential issue.
Then you can try and reactivating it as a git global setting, or a repo per repository basis.