2

We all know you can set Git email and username in git.config.

What's the best approach when two users use the same machine?

1
  • 1
    They should have different user accounts on the machine, so this shouldn't be an issue. Commented Apr 2, 2016 at 11:36

3 Answers 3

2

If having separate user accounts was not an option, I'd write a small script to set these GIT_AUTHOR_*** environment variables: https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables#Committing

Sign up to request clarification or add additional context in comments.

Comments

1

The sequence of actions:

  1. Create a dedicated group for these two users, and include them into the group. Re-login to apply the changes, if necessary.
  2. Create a shared repo in a location accessible by the users. with git init --shared
  3. Run chown -R :<the_group> . inside the repo.
  4. Now your users may clone the repo (git clone /path/to/the/repo from within their home folders) and work each in their private repo clones with their own personal settings, including name and e-mail. They need to publish their work periodically with git push.

Comments

1

If you interested in adding user information on commits, you can set author on each commit.

git commit -m "some message" --author "[email protected]"

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.