1

I'm trying to install GitHub, but it will not create the config file. I was following a tutorial that my university gave me, but it doesn't work on my laptop.

I keep getting an error saying fatal: unable to access 'C:\Users<MYNAME>/.config/git/config': Invalid argument. Every git related command I've used produces the same error. For example (but not limited to):

git config --global
git config --global -l
sudo git -c core.editor=ls\ -al config --system --edit.

When I try uninstalling and reinstalling, the installer throws the same error: st derr: fatal: unable to access 'C:\Users\<MYNAME>/.config/git/config': Invalid argument

Set home returns:

HOME=C:\Users\<MYNAME>
HOMEDRIVE=C:
HOMEPATH=\Users\MYNAME

I also cannot see the config file. There is no .config folder, and there is no .gitconfig file in /git/mingw64/etc so I'm at a loss. I've tried using the search function for my C: drive to try and find gitconfig, but I can't find it.

My computer's native language is Chinese (and I cannot change it without upgrading to windows pro), so maybe this is causing an error. I have no idea what to do.

Harsh Patel
  • 6,334
  • 10
  • 40
  • 73
AngryBo
  • 11
  • 1

1 Answers1

0

First, try the same commands from a simple CMD, with a simplified PATH (to rule out any PATH issue).
Make sure to use the latest Git for Windows (2.39.1)

set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
set "GH=%ProgramFiles%\Git"
set "PATH=%GH%\bin;%GH%\cmd;%GH%\usr\bin;%GH%\mingw64\bin;%GH%\mingw64\libexec\git-core;%PATH%"

Try a git init test, followed by cd test and:

git config -l --show-origin --show-scope

That way, you will see what folders Git is accessing when listing settings.


From the documentation, the only reason for Git to look for a git/config file is for an environment variable named XDG_CONFIG_HOME to be set to %USERPROFILE%/.config.

You can check if you have such a variable with:

set XDG_CONFIG_HOME
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • The current installation I'm using is the most recent one. I have also tried in the past with older ones. I tried putting the commands in the normal windows command window and the git command window, and both return the same errors. For the code you've included the first 3 lines don't throw an error (although I'm not sure how to tell if they've executed). The last three return: "fatal: unable to access 'C:\Users\/.config/git/config': Invalid argument" "The system cannot find the path specified." "fatal: unable to access 'C:\Users\/.config/git/config': Invalid argument" – AngryBo Feb 13 '23 at 16:43
  • @AngryBo Do you have a `%USERPROFILE%\.gitconfig` file? – VonC Feb 13 '23 at 19:23
  • I don't have .gitconfig file in C:\Users\NAME\ I have a bunch of other files like .conda, .jupyter, .matplotlib, etc. though. Also on my computer it auto makes names with the "\" slash, but github seems to want to use the "/" slash. Is this an issue? – AngryBo Feb 13 '23 at 20:16
  • @AngryBo GitHub? This should be related to Git only. Just for testing, can you create a `.config\git` folder in `%USERPROFILE%`, and a `config` file in it (even empty). – VonC Feb 13 '23 at 20:24
  • Sorry about the confusion. I did mean Git, I thought the terms were interchangeable - my bad. I created the folders, and made a config file by copying the "services" file in the "etc" folder in git and renaming it "config". Same errors. I tried making a .txt file, also same errors. Just to clarify, does %USERPROFILE% mean C:\Users\NAME or does it refer to something else? – AngryBo Feb 13 '23 at 22:56
  • @AngryBo Yes, `%USERPROFILE%` means `C:\Users\yourName`. The file should be config without extension. And you can create it empty, for testing. Git (versioning tool) is indeed different from GitHub (remote repository hosting service). See "[**Git vs. GitHub: What’s the Difference?**](https://devmountain.com/blog/git-vs-github-whats-the-difference/)". – VonC Feb 14 '23 at 06:57
  • I've tried it again with the empty file (I googled making an empty file), no luck. Is there really nothing related to the \ vs. / symbol? I just can't help but feel like it's weird that I'm getting an error that's showing both at the same time. – AngryBo Feb 14 '23 at 16:28
  • @AngryBo I agree the \ vs. / is suspect, but Git For Windows is supposed to support both. What version are you using? – VonC Feb 14 '23 at 20:31
  • I'm using windows 10.0.19044 and git version Git-2.39.1-64-bit – AngryBo Feb 15 '23 at 16:22
  • @AngryBo after reading [this comment](https://stackoverflow.com/questions/12254076/how-do-i-show-my-global-git-configuration#comment117141746_46986031), can you type `set XDG` and see if you have any variable starting with XDG? – VonC Feb 15 '23 at 18:28
  • I get "Environment variable XDG not defined" in both normal command prompt and git command prompt. Is this for windows? When I google XDG I see a lot of Linux related questions. – AngryBo Feb 15 '23 at 20:18
  • @AngryBo My point was: if this variable was defined, then this will explain why Git tries to look for config there. But if not... I confirm my Git for Windows does not look there at all. Only `%USERPROFILE%\.gitconfig`. – VonC Feb 15 '23 at 21:02