permission denied trying to set global git config - windows

in visual code terminal, I am trying to create user account with the command git config --global user.name "Tari shah", but I am keep getting the error
error: could not lock config file C:/WINDOWS/system32/config/systemprofile/.gitconfig: Permission denied".
please let me know how to resolve this issue.

That looks like VSCode was launch with the System account or Administrator account, but not your own Windows account.
Try the same command in a regular CMD session, opened regularely (not as admin): it should write in %USERPROFILE%\.gitconfig.
You can see that with (using Git 2.27):
git config -l --show-origin --show-scope
So try and re-launch your VSCode from your Windows account.

Related

Git config error when trying to set name and email

I'm new to Git and Github and I'm just trying to set up my desktop client to be able to upload my projects.
When trying to commit I get this error from the desktop client:
Author identity unknown
*** Please tell me who you are.
Run
git config --global user.email "you#example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'wsm1u#DESKTOP-5ICE6RR.(none)')
So then I use Windows Powershell and get this error:
PS C:\WINDOWS\system32> cd $HOME
PS C:\Users\wsm1u> git config --global user.email "wsm1usa1va1b#gmail.com"
>>
error: could not lock config file C:/desktop/.gitconfig: No such file or directory
Basically, I think the problem is that Git is searching for the config file in the wrong place, but I'm not sure how to have it search elsewhere.
Here are the solutions I've tried:
uninstalling and reinstalling Git
running Windows Powershell as admin (this gives back the same error message)
Pasting a copy of .gitconfig in my desktop (this didn't work so I deleted it)
running git lfs install --force to reset Git configuration, this gave the error message warning: error running C:\Program Files\Git\mingw64\libexec\git-core\git.exe 'config' '--includes' '--global' '--replace-all' 'filter.lfs.clean' 'git-lfs clean -- %f': 'error: could not lock config file C:/desktop/.gitconfig: No such file or directory' 'exit status 255' Run "git lfs install --force" to reset Git configuration.
Tried to locate a .gitconfig.lock file as per this solution: https://askubuntu.com/questions/258288/trouble-setting-up-git-error-could-not-lock-config-file
Here is my system info: System information
Thank you for your help! :)
TL;DR
I set my HOME
Found some gitconfig files in my trash and deleted them
I was able to set name and email through cmd as admin.
I was able to commit!
Long version
I ran cmd: set HOME and got
C:\Users\wsm1u>set HOME HOME=C:\desktop HOMEDRIVE=C: HOMEPATH=\Users\wsm1u
I went to: https://superuser.com/questions/246731/how-do-i-change-homedrive-homepath-and-homeshare-in-windows-xp ⇒ Marc B's solution (setting home path through "advanced system settings")
Committed through GitHub desktop -> got "tell me who you are" error
Set email in cmd -> got blank return
Set name -> got "permission denied" error
Ran cmd as admin
Set name -> got blank return
Tried to commit again and "Please tell me who you are" error again.
Ran git.bash as admin and set name/email then ran git config ‒list and got correct name and email returned
Tried to commit and got "please tell me who you are" error again
I tried creating a copy of my github desktop client in the program files directory because that is where my git directory is located. I thought maybe the client would only be able to find it that way (this made sense in my head) and that didn't work, so I deleted it.
While I was in progam files though I noticed that there was a .gitconfig there and so I deleted that, then I emptied my trash and noticed there were more in there.
Then I ran git config ‒list again and the name and email were gone from the return
Then I set name and email again in cmd as admin and I WAS ABLE TO COMMIT FOR THE FIRST TIME!!!

git init permission denied if no access to part of the path

We've been trying to get git to work inside a windows server environment (version 2012 and 2016). It works mostly well, but our new user data storage moved to this CIFS-like shared drive (instead of local drives) and git init has permission trouble (trying this with git 2.29.2)
These are the steps to reproduce:
I have some code in this shared drive:
\\data-dist\DataVol_014\group\users\myusername\mycode\
So I navigate there with Windows file explorer and then right-click to call git bash here.
Git bash opens and then when I type git init, I get the following error:
fatal: Invalid path '//data-dist/DataVol_014/group': Permission denied
We certainly have read/write/modify access to the following levels of this path
\\data-dist\DataVol_014\group\users\myusername\mycode\
\\data-dist\DataVol_014\group\users\myusername\
\\data-dist\DataVol_014\group\users\
However, I CANNOT even view these levels:
\\data-dist\DataVol_014\group\
\\data-dist\DataVol_014\
And can ONLY view here:
\\data-dist\
Any clues how to get this to work?

Jenkins git authentication failed with correct credentials on Windows

I'm currently using Jenkins on Windows 10, and using git as version control system.
Although I provided correct repository URL and credential, I cannot use jenkins with error below.
Failed to connect to repository : Command "git.exe ls-remote -h REPOSITORY_URL HEAD" returned status code 128:
stdout:
stderr: git#URL: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Credential and URL doesn't seems wrong, since this build success previously with same credential. The only change after successful build was one line in build script.
git config --global core.sshCommand C:/Windows/System32/OpenSSH/ssh.exe
After I success with this script, git setting keeps failed. Is there any problem with that line? And how can I fix it?
EDIT
Problem solved! For anyone who has same problem, it was problem with the system user! Since ssh key stores in each user space, jenkins cannot detect where the ssh key located. Therefore, go to 'service' in windows, and change user of jenkins service to the user who has correct ssh key. It solved my problem!
Seems there is some problem in Jenkins.
It cannot locate OpenSSH folder in System32, and so that I cannot get log with it.
That would explain why the main Jenkins controller (aka "master" in old terminology) cannot contact the Git repository (assuming an SSH URL here, with technical remote user account "git")
Try and remove that git configuration to see if the error persists: Git should fall back to its own ssh.exe, packaged with Git For Windows.
As noted by the OP, this only works if said Jenkins is run as a user account, not as the system account.
Only then will it be able to access the %USERPROFILE%\.ssh folder.

Git config command showing permission denied

I'm new to Git and repeatedly getting the following error.
When I type the command git config --global color.ui auto I get the error:
error: could not lock config file C:/Program Files/Java/jdk1.8.0_101/bin/.gitconfig: Permission denied
I have been getting the same permission denied error for other commands as well. I don't know if there is any problem with the path.
HOME should not be set to the JDK bin folder, but to your %USERPROFILE%.
Do check in a CMD session the value of your account:
set USER
You should see your username and USERPROFILE folder.
Then try the same git config command, in that CMD session, setting HOME first:
set HOME=%USERPROFILE%
I was facing permission denied for git config --global user.name command from Git bash in Windows.
I ran the Git bash with Administrator privileges and was able to resolve the error.
Note: I also got the same error from Intellij trying to commit changes; that too got resolved after running Intellij in Admin mode.
I had the same issue, trying to set the initial configuration for git - user.name and user.email and failing with a "Permission denied" error. It failed in Normal and Administrator mode and on all CLIs - PowerShell, CMD and GitBash.
The reason in my case was rather stupid. Somehow I had a ~/.gitconfig folder, rather than a file, so the CLIs were failing to create the file, due to filename conflict. Although the error message could have been more helpful.
The solution - just delete the folder and try again.

Installing git on Windows 10, unable to access .gitconfig

I'm new to git, and i'm trying to install git 2.9.2 from here. In the installation (the last of the many) i chose to run it from bash only. I now try to set it up, and the first thing i try is to set my name with
$ git config --global user.name "My Name"
But after i execute this, i get:
fatal: unable to access 'C:\Program Files\Git\ C:\Windows\system32\config\systemprofile/.config/git/config': Invalid argument
Let's say that i now want to clone a repository. I insert something like:
git clone https://username#bitbucket.org/team/repo.git
But i get:
fatal: unable to access 'D:\TestRepo\ C:\Users\username/.config/git/config': Invalid argument
I thought that the .gitconfig file should be inside the C:/Users/username directory, but it tries to locate C:\Users\username/.config/git/config, which seems a little weird. My HOME variable is %USERPROFILE%, as it should. Any help appreciated.
Ok i guess my lack of knowledge over basic things made me look stupid...
I just had to delete the HOME environmental variable and all worked like charm. I don't even remember why i had a HOME variable set (isn't that a linux thing?)
Anyway thank you for your time guys.
Did you use git init on the folder you are trying to operate from?
Also you need to configure your username and the email to your github account for it to work properly.
git config --global user.name "username"
git config --global user.email "email#gmail.com"
Finally, if you have a space in your name please remember to escape it. ex: "my name" = "my\ name"
did you set up your remote repository?
git remote add origin https://github.com/rodoggx/yourRepository.git
Same issue. But if I run with command shell (not bash) with Admin level, git config --global -l works. My git version 2.25.0.windows.1
I noticed that in the System Info gui of Windows, the env variables for System had a HOME entry of %USERPROFILE%. But, the User env variables did not. I added HOME to that too.
Now it works. You'd think the System env would fill in for those not in User. Maybe something else is going on.

Resources