1

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 "donhuvy@outlook.com"

it did not work.

(2) I tried config for local git repository

git config user.name "Do Nhu Vy"
git config user.email donhuvy@outlook.com

it did not work.

(3) I tried use Windows PowerShell (Administrator)

git config user.name "Do Nhu Vy"
git config user.email "donhuvy@outlook.com"

it did not work.

enter image description here

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
user.email=74403808+vyolbius@users.noreply.github.com
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
user.email=donhuvy@hotmail.com
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?

Vy Do
  • 46,709
  • 59
  • 215
  • 313

3 Answers3

3

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • This is my power shell log https://gist.github.com/donhuvy/ebd637cd4b02ae5130533a431bf02d64 and commit https://github.com/donhuvy/jqxwidgets but I still see `user.name=vyolbius` I tend/want/imagine it is `user.name=donhuvy` . – Vy Do Jan 19 '21 at 08:14
  • 2
    @DoNhuVy Yes, you see it in the global config: it is overridden by the local config, so it is all good. – VonC Jan 19 '21 at 08:17
1

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 "donhuvy@outlook.com"

That will only affect repositories where the email isn't set locally. To set an email locally do

git config --local user.email "donhuvy@outlook.com"

The global and local flags work for all and are necessary for all settings.

Vy Do
  • 46,709
  • 59
  • 215
  • 313
jaaq
  • 1,188
  • 11
  • 29
  • It did not work as you and me expected https://gist.github.com/donhuvy/a55b0d07036788a42e5f9bf983e7fae7#file-git_local-log-L203-L204 – Vy Do Jan 19 '21 at 08:17
  • https://user-images.githubusercontent.com/1328316/105006606-78390200-5a69-11eb-968b-dea9c63b1b8b.png – Vy Do Jan 19 '21 at 08:17
  • is that folder a git repo? Does it have a hidden `.git` folder? Also try to list it with `git config --list --local` – jaaq Jan 19 '21 at 08:28
  • I see screenshot again, it is exactly local git repository in my PC. Oh, it work now https://user-images.githubusercontent.com/1328316/105015061-b9ceaa80-5a73-11eb-959f-a4971bd3f7fa.png – Vy Do Jan 19 '21 at 09:30
1

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.)

torek
  • 448,244
  • 59
  • 642
  • 775