Roman Goyenko
Roman Goyenko

Reputation: 7070

Switch users in git

I have a following scenario:

We have environment with custom program that several people develop in - basically shared file system location and it's under Git control.

People change stuff in this location. I want to be able to switch users when they commit - what's the easiest way to do it?

Upvotes: 2

Views: 972

Answers (4)

Alex Correa
Alex Correa

Reputation: 39

On each machine should have 1 User git, configured with the command git config --global user.name = USER_NAME and git config --global user.email = USER_EMAIL, Do you need to have multiple users on the same machine? If it, I think the easiest way is a script that requests User and email before commit, to run this commands before commit.

Upvotes: 1

Pfryling
Pfryling

Reputation: 13

If you just want to change the username of the person who makes the commit:

git commit --author="Author Name <[email protected]>"

Upvotes: 0

infused
infused

Reputation: 24337

As long as each person is logged in with their own separate account, make sure that each of them has a .gitconfig file in their home directory.

Add a [user] section and define the name and email:

[user]
name = John Smith
email = [email protected]

Upvotes: 2

progrenhard
progrenhard

Reputation: 2363

Create separate branches for each person working on the project. I suppose you could think about it like usernames and then you can git checkout <branchname> (this switches between branches) then you will all have you own repos and be able to store you own commits.

Upvotes: 0

Related Questions