Reputation: 1587
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.
Upvotes: 1
Views: 20398
Reputation: 119
I solved that. By adding .gitconfig file to the Home directory. Now it works fine.
Upvotes: 0
Reputation: 11
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.
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.
Upvotes: 1
Reputation: 1587
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 = [email protected]
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
.
Upvotes: 5