Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use git (git config --global)?

The Pragmatic Guide to GIT has the following "Git uses both to calculate the commit ID—a SHA-111 hash—that identifies each commit." in page 21.

And in page 22, I can use the following command to 'Configure Git to know who you are'.

 git config --global smcho "Your Name" 

When I ran it, I got the following error message.

 error: key does not contain a section: smcho 

What's wrong with this? I guess it has something to do with SHA-111 hash, but I don't know how to get it to be used with git.

ADDED

I thought user.name is to be replaced my name, not a section/parameter structured name. After changing that it works OK.

 git config --global user.name "Your Name" 
like image 375
prosseek Avatar asked Aug 27 '10 01:08

prosseek


People also ask

What is the use of git config -- global?

The git config command is a convenience function that is used to set Git configuration values on a global or local project level. These configuration levels correspond to . gitconfig text files. Executing git config will modify a configuration text file.

What is git config --'global user name?

To set your Git username, run the git config –global user.name command. You should specify both your first and last name but your username can be anything you want to attach to your commits. Your Git username does not need to be the same as your version control username, such as the one you use on GitHub.

What is global in git?

2. Global: Global configurations are available for the current users for all the projects and stored in. ~/.gitconfig or ~/.config/git/config. Example: C:/Users/Username/.gitconfig. You can make git to read and write from Global by passing --global option.


2 Answers

Not sure where "smcho" comes from, but the setting to set your name is user.name:

git config --global user.name "Your Name" 

You can set your e-mail address too:

git config --global user.email "[email protected]" 

I guess the reason it complains about the lack of a section is that the name of the parameter to set probably needs to be in two parts: section.parameter_name (You can see the sections names within [] if you look in the configuration file, for example in .git/config).

(None of this is specific to OSX as far as I'm aware.)

like image 168
Bruno Avatar answered Sep 22 '22 10:09

Bruno


A simple answer to this question/problem is that do not replace "user.name" with your actual git username leave the user.name as it is the command needs to be:

git config --global user.name "Your Name here only" 
like image 22
user_CC Avatar answered Sep 24 '22 10:09

user_CC