Jie Zou
Jie Zou

Reputation: 35

How can I create a new Git configuration file?

I want to configure Git, but I deleted my configuration file before (a big mistake). It shows me

No such file or directory

when I put in ~/.gitconfig:

$ git config global user.name "a"
error: key does not contain a section: global
$ ~/.gitconfig
-bash:/.gitconfig: No such file or directory

Upvotes: 2

Views: 1875

Answers (1)

Chris
Chris

Reputation: 136880

Add dashes to global:

git config --global user.name "a"

Without the dashes global is getting interpreted as a section, but that's not valid. You want the --global flag.

The file doesn't need to exist before you run this command. Git will create it if it's not there.

Upvotes: 1

Related Questions