1

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.

5
  • 2
    If touch ~/.gitconfig fails, your problem has nothing to do with git. Is there any file there? Do other filenames work? Commented Jan 25, 2015 at 23:59
  • There is a file .gitconfig@ at my root directory - what does the @ mean? I cannot view this file Commented Jan 26, 2015 at 0:04
  • 1
    The @ suffix is something various programs add to indicate that this is a symbolic link. Apparently it's a symlink to a non-existent file. Find out where it was linked, and what happened to wherever-that-was, if you want to get the previous contents back. Commented Jan 26, 2015 at 0:06
  • Is there a way I can just have Git create the file from scratch again? Commented Jan 26, 2015 at 0:13
  • 1
    If you don't care what it might have been pointed at before then just delete the broken/dangling symlink and try the git config command again. Commented Jan 26, 2015 at 2:19

3 Answers 3

5

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Were you ever able to solve this? I am running into the same problem and have yet to find a solution.
On windows, my gitconfig file was present at C:\Program Files\Git\etc\gitconfig
1

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.

  1. create a folder structure c:/dev/home if already not present.
  2. Open the Windows command prompt. (Run as administrator)
  3. From the Windows command prompt, run the command "git init"
  4. Run the following command: git config --global user.name "Example"
  5. Run the following command: git config --global user.email "[email protected]"

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.

Comments

0

I solved that. By adding .gitconfig file to the Home directory. Now it works fine.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.