Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 10 down vote accepted

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 <john.doe@example.com>" file1.dat file2.dat
$ git log --pretty=full
commit 46963e65f337fa08cfbebcd09ddf248474d49212
Author: John Doe <john.doe@example.com>
Commit: Johannes <johannes@example.com>

     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 john.doe@example.com

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

share|improve this answer
    
Thanks - that last option will make my chores easiest. –  alex.jordan Aug 18 at 4:53
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. –  Federico Poloni Aug 18 at 8:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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