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
?
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.
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.
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.
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.
--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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With