4

I have a central git repo located on a server. I have many contributors that are not tech savvy, do not have server access, and do not know anything about git. But they are able to contribute via the project's web side. Each of them logs on via a web browser and contributes to the project.

I have set things up so that when they log on, each user's contributions are made into a cloned repo on the server that is specifically for that user. Periodically, I log on to the server, visit each of their repos, and do a git diff to make sure they haven't done anything bad. If all is well, I commit their changes and push them to the central repo.

Of course I need to manually look at their changes so that I can add an appropriate commit message. But I would also like to track who made the changes. I am making the commit, and I (and the web server) are the only users that are actually writing anything to the server.

I could track this in the commit messages. While this strikes me as wrong, if this is my only option, is there a way to make userx's cloned repo always include "userx: " before each commit message that I add, so that I do not have to remind myself which user's repo I am in?

Or even better, is there an easy way for me to make the commit, but in such a way as I credit the user whose cloned repo I am in?

1 Answer 1

10

In git there are two names associated with a commit. An "author" and a "committer". In Your case you want to be the commiter and set the "author" accordingly using git commit's --author option.

$ git commit --author "John Doe <[email protected]>" file1.dat file2.dat
$ git log --pretty=full
commit 46963e65f337fa08cfbebcd09ddf248474d49212
Author: John Doe <[email protected]>
Commit: Johannes <[email protected]>

     Sample commit

Alternatively if the workspace is specific to the user you could simple configure the username accordingly

$ git config --local --add user.name "John Doe"
$ git config --local --add user.email [email protected]

then they are tracked as committer and author for all commits from that clone.

1
  • 1
    Note also that if the author already exists (with their e-mail) in the commit database, a uniquely identifying substring such as --author=John will do. Commented Aug 18, 2014 at 8:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.