Letting multiple users write to a repository does not mean that you will be able to determine “who has done what”.
It is true that the first (server-local) user to create a particular object (blob, tree, commit, annotated tag) will be the owner of the object’s loose object file (though any other user with write access could probably delete and rewrite the file), but ultimately those loose object files are ephemeral. The individual loose objects will eventually be packed and deleted (e.g. via git gc
, either manually or automatically once enough loose objects have accumulated).
Git does neither authentication, nor authorization, thus is has no idea about the “user” that is doing a push1. Since it has no concept of the active user, it can not provide a log of “who pushed/modified/deleted what”. If you need such an audit log, you will have to rely on whatever tool is actually doing the authentication. Unfortunately, many Git hosting tools focus on the distributed nature of Git so they tend not to offer much support for “centralized” features like an audit log. There are some exceptions, though:
- Gitolite keeps a log that might be usable as an audit log (the authentication is done by either the SSH server or the HTTP server, but Gitolite does the authorization).
- Gerrit seems to have some built-in restrictions that try to more strongly associate the committer (and author, depending on configuration) user information with the authenticated user accounts (see Forge Identity); while this is not an audit log, it might suffice if you consistently restrict the “forging” authority.
(There are probably other tools or services that have some logging/restriction features, too.)
See Also: Git Log History
1
Git does keep track of an author and committer for each commit (tagger for each annotated tag), but their values are not restricted by Git. Anyone can change the effective author or committer by changing (or overriding) their user.email
and user.name
configuration variables or setting the GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, GIT_COMMITTER_NAME, and GIT_COMMITTER_EMAIL environment variables while making a commit or tag.