Reputation: 52488
My development environment:
PS D:\github\jqxwidgets> git --version
git version 2.30.0.windows.1
Windows 10 x64 version 2004. My repository https://github.com/donhuvy/jqxwidgets (just for learning a jQuery plug-in framework). In my PC has Github Desktop for Windows, but I use it for other project.
(1) I tried config for local git repository
git config user.name "Do Nhu Vy"
git config user.email "[email protected]"
it did not work.
(2) I tried config for local git repository
git config user.name "Do Nhu Vy"
git config user.email [email protected]
it did not work.
(3) I tried use Windows PowerShell (Administrator)
git config user.name "Do Nhu Vy"
git config user.email "[email protected]"
it did not work.
I don't want use git config --global ...
because on my PC has many projects has different remote server and different users.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS C:\WINDOWS\system32> cd d:
PS D:\> cd .\github\
PS D:\github> cd .\jqxwidgets\
PS D:\github\jqxwidgets> ls
Directory: D:\github\jqxwidgets
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 1/19/2021 2:48 PM .idea
d----- 1/19/2021 2:41 PM jqxGrid
-a---- 1/19/2021 2:39 PM 1714 .gitignore
-a---- 1/19/2021 2:39 PM 1544 LICENSE
-a---- 1/19/2021 2:39 PM 12 README.md
PS D:\github\jqxwidgets> git config user.name "Do Nhu Vy"
PS D:\github\jqxwidgets> git config --list
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
http.sslbackend=schannel
core.autocrlf=true
core.fscache=true
core.symlinks=true
pull.rebase=false
credential.helper=manager-core
credential.https://dev.azure.com.usehttppath=true
init.defaultbranch=main
user.name=vyolbius
[email protected]
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
remote.origin.url=https://github.com/donhuvy/jqxwidgets.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.main.remote=origin
branch.main.merge=refs/heads/main
[email protected]
user.name=Do Nhu Vy
PS D:\github\jqxwidgets>
PS D:\github\jqxwidgets>
PS D:\github\jqxwidgets> git --version
git version 2.30.0.windows.1
PS D:\github\jqxwidgets>
PS D:\github\jqxwidgets>
How to fix it?
Upvotes: 1
Views: 2048
Reputation: 1256
Did you try git config --local
? Also the global setting doesn't overwrite all other projects, rather it creates a default configuration that is used unless local settings are different.
So if you set your global email
git config --global user.email "[email protected]"
That will only affect repositories where the email isn't set locally. To set an email locally do
git config --local user.email "[email protected]"
The global and local flags work for all and are necessary for all settings.
Upvotes: 1
Reputation: 487725
It's not broken.
PS D:\github\jqxwidgets> git config --list [snippage] user.name=vyolbius [snippage] user.name=Do Nhu Vy
The first value comes from a "higher" or "more global level" / less-applicable setting, and the second value comes from the "more local level" / more-applicable setting. The second value overrides the first value.
(There are some Git settings that are cumulative. For these, you must inspect all the values listed by git config --list
or git config --get-all
. But user.name
and user.email
are not cumulative; they are last-one-listed-wins.)
Upvotes: 1
Reputation: 1323115
A local config will overwrite any global configuration.
Check yours with:
cd /path/to/my/repo
git config --show-origin --show-scope -l
Try and make a new commit: it should be authored with the right user name/email.
I always use (as documented here):
git config --global user.useConfigOnly true
That way, I am forced to set the right user.name/email on each new local Git repository.
Upvotes: 3