Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

global git config file does not exist

git: git version 2.10.1 (Apple Git-78)
macOS: 10.12.3


I am (was) having some issues with git, everything committed locally and then pushed up to GitHub is (was) not referenced in my account but rather committed by an unknown user.

I googled some online, as I always do, and came to this conclusion. The git config had been messed with. (Prev commits are fine etc.)

Naturally I tried setting my email in the git config to match the one on GitHub, this way GitHub would automatically notice the (new) commits are mine and everything would be fine..

So I ran

git config --global user.email <[email protected]>

Without success... The following error was returned to me:

error: could not lock config file /Users/<user>/.gitconfig: No such file or directory

I tried to reinstall/update git by downloading the latest version here.

Running git config --global -l to list all of the configs returns the following error:

fatal: unable to read config file '/Users/<user>/.gitconfig': No such file or directory

terminal screenshot


Conclusion

The file does not seem to exist. As you can see in the screenshot. Reinstalling git via their website did not initiate the config file.
I have no clue what to do...


Other posts:
I tried resolving this issue by going trough other related answers etc. However this did not help me resolve this issue. I think my case is a little more specific than most cases...


update

Tried to create the folders: update screenshot

like image 257
Jesse van der Pluijm Avatar asked Feb 05 '17 15:02

Jesse van der Pluijm


1 Answers

Try

rm ~/.gitconfig
touch ~/.gitconfig

to remove the bad symlink and create a new config file.

Then re-run you command to create the setting:

git config --global user.email <[email protected]>
like image 116
Harald Nordgren Avatar answered Oct 02 '22 02:10

Harald Nordgren