4

We have created a branch of our code on a testing server which multiple users are now working on by SSH'ing into the new server and doing all the committing with the command line. BUT, of course Git doesn't know whose making the changes and committing them, so we need to specify the author during the commit.

I thought we could achieve this with:

git commit -a -m 'removed temporary images' --author='deed02392 <foo@bar.net>'

But that gives:

[test-branch 77b9357] removed temporary image 
    Author: deed02392 <foo@bar.net>
    Committer: root <root@vs123.(none)>
    Your name and email address were configured automatically based on your username and hostname. Please check that they are accurate. You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

If the identity used for this commit is wrong, you can fix it with:

    git commit --amend --author='Your Name <you@example.com>'

 1 files changed, 0 insertions(+), 0 deletions(-)  delete mode 100644 derp.PNG

It seems too much to expect every user to change the config every time. Is this behaviour because Git is not designed to let multiple users play with one repository?

deed02392
  • 4,799
  • 2
  • 31
  • 48
  • 2
    You could give everyone their own user account. – Thomas Nov 27 '12 at 19:55
  • 1
    Multiple users *aren't* playing with one repository. One user is, and that user appears to be `root`. This is doubly bad practice. – Edward Thomson Nov 27 '12 at 19:57
  • um, are you really having many developers changing the same exact files with the same user account, concurrently...? I'm finding that really hard to believe. – eis Nov 27 '12 at 19:57
  • Ah, sorry, yes every user SSH's in with their own user account. But then we will get this message every time we commit because to store the username and e-mail in the config would then require it changing every time. Can we silence this warning? – deed02392 Nov 27 '12 at 19:59
  • 6
    if every user has their own user account, every user can configure it *once* in their own home folder, and you wouldn't have the issue, right? that's what `git config --global` does. – eis Nov 27 '12 at 20:02
  • Ah, that's what I was missing. I had assumed it stored the config data in the repository `.git` file. These makes much more sense now. – deed02392 Nov 27 '12 at 20:56

2 Answers2

4

as long as all users use different systems accounts, running

 git config --global user.***

once per user should fix the problem, even if all users work on the same repo, as those settings are user-specific and saved in $HOME/.gitconfig.

(of course) it will not work if they su to root or some other shared account before running git.

mnagel
  • 6,729
  • 4
  • 31
  • 66
2

Idea 1: Take a look at this link, which shows how to use environment variables to define the author names etc.

Idea2: Github for example has a generic 'git' user that's used by everyone to push changes to their repositories, and they distinguish users by, possibly amongst others, ssh keys. You could try something in that direction, though I'm not sure if it will work for your setting, as you're working directly on the server.

These links are related: this link, this one. Here's a link explaining how gitolite does the ssh magic

Community
  • 1
  • 1
m01
  • 9,033
  • 6
  • 32
  • 58