Michael Forbes <michael.for...@gmail.com> writes:

Hi,

I am trying to find a good solution to this use-case that seems to require
expansion in the .gitconfig file:

1. Multiple users share the same account on a machine (this is using CoCalc <http://cocalc.org> where the user is the project id so changing this is
not an option).
2. We would like to be able to use git, but with proper recording of which
user made the commit.

I work this with mercurial by having each user set an environment variable when they log in, and then adding the following to the project .hgrc file:

[ui]
username = $LC_HG_USERNAME

This fails in the .gitconfig file as expansion is not performed
<https://stackoverflow.com/questions/11262010/shell-variable-expansion-in-git-config/11262153#11262153>.
A workaround suggested there is to do something like this in the .bashrc
file:

git config --global user.name=$LC_GIT_USERNAME


This means, however, that all commits will be logged as the last user who logged in - which mucks up the use case where multiple people might be
logged in at the same time.

Any suggestions for how to get git to work nicely in this case?

If I understand you correctly you rely on the logged in user setting
$LC_GIT_USERNAME properly, how is that done?

If it's done using some script, maybe you can simply modify that script
to *create* the proper ~/.gitconfig at the same time?

/M

--
Magnus Therning              OpenPGP: 0x927912051716CE39
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe               http://therning.org/magnus

Sometimes I wonder whether the world is being run by smart people who
are putting us on or by imbeciles who really mean it.
    — Mark Twain
Clearly, it's the imbeciles. And they really mean it.
    — DBT

--
You received this message because you are subscribed to the Google Groups "Git for 
human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: PGP signature

Reply via email to