marcelosalloum
marcelosalloum

Reputation: 3531

HOW TO reconfigure git user?

I've just got a friend's computer and I need to reconfigure the GIT to my user account. I read that you can change the user name by typing git config --global user.name "My Name" but this probably won't change the user itself, just its name.

Any hints? Cheers,

Upvotes: 0

Views: 4876

Answers (3)

helmbert
helmbert

Reputation: 37994

That depends on how you connect to the repository. For one, the username could be hardcoded in the remote repository's URL (e.g. ssh://user@hostname/my/repository.git -- you can check with git remote -v). In this case you can just change the remote URL using git remote set-url origin ssh://....

If you use SSH to connect, the username could also be configured in the SSH configuration file (on UNIX in ~/.ssh/ssh_config). Then, some services use the client's SSH key to identify the user (in which case you would probably have to switch your SSH key).

If you are authenticating anonymously, you can just change the config settings.

Upvotes: 0

Wes Crow
Wes Crow

Reputation: 2967

Git global user config values are saved in the user path. So if you are logging in with a different user account, you can set the global config values and it basically takes those user values, leaving the former user's values in tact under their account.

Upvotes: 0

fge
fge

Reputation: 121710

git doesn't care about your user name. Well, yes, it cares in one situation:

  • if you do not have user.name setup, it will default to the system's user name;
  • if you do not have user.email configured, it will by default append the system username, '@', and the hostname of the machine you are on;

So, in the end, you really have to ensure about two things:

  • you have a user.name and user.email properly set;
  • your "new user" has the necessary privileges to operate the repository.

Also note that the name and email settings may be overwritten on a per repository basis. Check the .git/config of existing repositories as well.

Upvotes: 1

Related Questions