Fix "Updates were rejected because the remote contains work that you do not have locally"
Someone pushed commits to the branch after you last pulled, so pushing would erase their work. Run git pull to combine their commits with yours (resolving conflicts if any), then git push again.
Step by step
Get your teammates' commits and merge them into yours:
$ git pullIf there are conflicts, resolve them, then:
$ git add <file>$ git commitPush again:
$ git push
The full message is ! [rejected] main -> main (fetch first) and hint: Updates were rejected because the remote contains work that you do not have locally. Avoid git push --force: it overwrites your teammates' commits.