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

64,259

Solution 1

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.)

Solution 2

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"

Solution 3

to edit the whole config file

git config --global --edit
Share:
64,259
prosseek
Author by

prosseek

A software engineer/programmer/researcher/professor who loves everything about software building. Programming Language: C/C++, D, Java/Groovy/Scala, C#, Objective-C, Python, Ruby, Lisp, Prolog, SQL, Smalltalk, Haskell, F#, OCaml, Erlang/Elixir, Forth, Rebol/Red Programming Tools and environments: Emacs, Eclipse, TextMate, JVM, .NET Programming Methodology: Refactoring, Design Patterns, Agile, eXtreme Computer Science: Algorithm, Compiler, Artificial Intelligence

Updated on July 27, 2022

Comments

  • prosseek
    prosseek almost 2 years

    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"
    
  • rayhem
    rayhem over 13 years
    You can also set the user.name and user.email fields on a per-repository basis. If you have the defaults set, just change into the directory with the .git folder and run the commands again without the --global flag. Came in useful for me when I started using GitHub, so I could hide my 'real' or work email address.
  • Dan Rosenstark
    Dan Rosenstark over 13 years
    @ConnorG, THANKS that is exactly what I was about to ask, and exactly for the same reason!