Git config command showing permission denied - windows

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.

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!!!

permission denied trying to set global git config

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.

Win 10 + Git - unable to create file - permission denied

This is really not a duplicate question. I tried few solutions like reset head^ , git checkout -- <file>,... but this does not solve my problem. The problem is that I can not revert the index.php file from "Changes not staged for commit" from git status because it throws me an error:
Unable to create file www/index.php: Permission denied during executing git "C:\Program Files\Git\bin\git.exe" -c
core.quotepath=false checkout HEAD -- www/index.php
I dont understand what is wrong with that. I am an admnistrator, console runs as administrator.. I have all permissions to do this so what permission I need? What the hell is wrong? Help me please I am in the end.
When I did git checkout -- www/index.php this didn't work for me so My problem was happening because the antivirus had moved my file www/index.php to the virus trunk (baúl de virus)
The problem with Git error - permission denied in this case has been caused by the incriminated file was open in other process. The solution was to shut down all the apps except one console, then run git checkout -- www/index.php and everything works as excepted without any trouble.

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.

Can't configure git, missing .gitconfig file

when I try to config Git I receive the following error:
$ git config --global user.name "John Smith"
error: could not lock config file /Users/John/.gitconfig: No such file or directory
My root directory is completely missing a .gitconfig file. When I try to make a new one I receive this error:
$ touch ~/.gitconfig
touch: /Users/John/.gitconfig: No such file or directory
My git's location:
$ which git
/usr/local/git/bin/git
I've tried reinstalling Git several times (running OSX Yosemite) and I'm still having the same issue. I also cannot locate any .gitconfig.lock files, as mentioned in some posts regarding this issue.
So I ended up solving this issue by reading the Customizing Git section of the documentation.
While I could not touch a new .gitconfig file in my root directory as stated above, I read that the first place Git looks for configuration values is in etc/gitconfig (note the lack of a . in the name).
So I created a file called gitconfig inside of the etc directory and filled it in with a sample gitconfig I found online, and added my user information to the top like so:
[user]
name = John Smith
email = jsmith#example.com
I was then able to commit as my usual self, however I still don't have a .gitconfig in my root, so I am unable to config Git using git config --global, and must do the configurations manually in etc/gitconfig.
For me the .gitconfig file was missing.I tried reinstalling Git several times, however it din't help me. I resolved the issue by performing the below steps.
create a folder structure c:/dev/home if already not present.
Open the Windows command prompt. (Run as administrator)
From the Windows command prompt, run the command "git init"
Run the following command:
git config --global user.name "Example"
Run the following command:
git config --global user.email "Example#gmail.com"
The above steps will create the .gitconfig file in the path c:/dev/home and you will be able to set your desired username and email id.
On Windows systems, Git looks for the .gitconfig file in the $HOME directory (C:\Users\$USER for most people). So copy the file created in the above step to your Home directory by providing the required permission.
I solved that. By adding .gitconfig file to the Home directory. Now it works fine.

Resources