Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git --global switch related to one user or all user?

Tags:

git

linux

Suppose I have two users A and B in my Linux system. I am logged in as user A. If i configure an option using the --global switch like this

git config --global user.name "my name"

Will this set option only for user A? Or it will affect both users: A and user B?

like image 546
chanchal118 Avatar asked Mar 17 '14 09:03

chanchal118


People also ask

Is git config global for all users?

One thing to note is that each user gets their own global Git config file. This can cause problems if you run a shell script with sudo command. If sudo is used in a script, the ~root/. gitconfig file will be used instead of the global git config file of the user running the script.

What is global user name in git?

The global git username and email address are associated with commits on all repositories on your system that don't have repository-specific values. You can also edit the file with your text editor, but it is recommended to use the git config command.

What does global mean in git?

Global level configuration is user-specific, meaning it is applied to an operating system user. Global configuration values are stored in a file that is located in a user's home directory. ~ /.gitconfig on unix systems and C:\Users\\.gitconfig on windows. --system.

How do I switch between users in git?

Changing To a Different Git User If you want to switch to a new user, just call the same command and pass in a string of the email address. I recommend using the the --global flag, but it's not always necessary.


1 Answers

--global is the option to for configuring stuff for the current user. It stores data into you home directory in ~/.gitconfig by default, or ./.config/git/config if the file exists and ~/.gitconfig does not.

--system is the option for all users, you probably need root access to use it and it stores data into /etc/gitconfig.

If you don't use any of them, that's the repo specific config going into .git/config.

See the OPTIONS section of git config's documentation for details.

If there are conflicts for a certain parameter, the smaller scope config wins.

like image 61
SzG Avatar answered Sep 20 '22 21:09

SzG