Git does not handle any authorization. The way it works, you can just change your identity using git config
or the --author
argument to make commits as whoever you want. These commits will stay local to your computer until you decide to push them.
Remote servers often opt in to have some sort of authentication. This is most commonly done using the SSH protocol. In addition, many add a authorization layer that restricts you from accessing repositories. For example on GitHub, you may only push to repositories that you own or to which you explicitely got write access.
This access control however does only apply to the act of pushing changes. So if you have access to a repository, you can push whatever commits you want, with whatever author you want. It is possible that providers add a check that rejects pushes when they contain commits that are not authored (or committed) by the pushing user. However, this behavior is usually not desired.
The reason for that is that Git is a distributed version control system. So unlike for example Subversion, people don’t have to use the same centralized server which can then ensure that you only publish changes made by yourself (Subversion actually just assumes this and the “commits” are only created on the server). Instead, it is possible—and often desired—that commits go different routes until they land on central repositories (multiple repositories are common too). You could even work directly with another developer and push changes into, or pull changes from their private repository without ever having to interact with some sort of central server. And when you then decide to publish commits to a central server, of course that central server should not reject your changes just because you included commits by that other developer.
So no, there is no guarantee that someone else isn’t using your “identity” to create commits in your name. Git does however support signing commits, to allow you to prove that a commit is of your own. Anyone that is then interested in validating it can then check the signature on the commit and verify that it was really made by yourself. Some repository servers may even require that all commits that are pushed to the server are signed, and then verify the signature on each commit. But that is totally optional and not something Git comes with by default; because by default Git is just a “stupid content tracker”.