Trouble setting up git with my GitHub Account error: could not lock config file

后端 未结 19 1588
甜味超标
甜味超标 2020-11-28 05:52

I\'m getting this error when trying to set the global config:

$ git config --global user.name \"Your Name Here\"
error: could not lock config file /pathto/fi         


        
相关标签:
19条回答
  • 2020-11-28 06:20

    In Windows: Right click on "Git Bash" icon -> Run as Administrator. it helped me.

    Git tries to create a config file on disk C:/ but it has no permission to do that.

    0 讨论(0)
  • 2020-11-28 06:23

    I started getting this error after windows upgrade. My Home variable somehow removed after windows upgrade. Issue resolved by adding HOME variable as "C"\Users\myusername".

    0 讨论(0)
  • 2020-11-28 06:25

    A bit like in "Trouble setting up Tower with my GitHub Account - error: could not lock config file", check how that ~/.gitconfig file has been created.
    Ie: with which rights associated to it?

    Make also sure your $HOME variable is correctly set when you are executing the git config --global command.

    0 讨论(0)
  • 2020-11-28 06:25

    Just use the following command if you wanna set configuration in system level:

    $ sudo git config --system user.name "my_name"
    
    0 讨论(0)
  • 2020-11-28 06:25

    In my case, the .git/config file was created not in my $HOME directory, but inside my repository on .git/config.lock

    Deleting the file fixed the problem. The file is created, when I switch branches with git checkout -f branchname and files from a recently created submodule were overwritten by git checkout.

    $ git branch --set-upstream-to=origin/branchname
    error: could not lock config file .git/config: File exists
    error: Unable to write upstream branch configuration
    hint: 
    hint: After fixing the error cause you may try to fix up
    hint: the remote tracking information by invoking
    hint: "git branch --set-upstream-to=origin/branchname".
    
    0 讨论(0)
  • 2020-11-28 06:30

    This could be caused by the presence of ~/.gitconfig.lock It's possible this file could be an artifact of a previously running git that was aborted for some reason, e.g. ansible timed out or ^C

    0 讨论(0)
提交回复
热议问题