2 | Configuring Git |
Git requires some configuration to work. You must tell Git your name and your email address since there is no central repository to keep track of that information. Git uses both to calculate the commit ID—an SHA-1[11] hash—that identifies each commit.
The first two commands on the next page use --global to specify that they are configuration values for every repository you interact with on this machine. The configuration file is stored in ~/.gitconfig. You can edit the file directly in addition to using the git config command.
You can set every setting on a global or per-repository basis. By leaving --global out of the command, the settings will be stored in the repository’s .git/config file.
You might want to set a few other useful configuration values while configuring Git. You can set color.ui to auto if you like to have your command-line interfaces colorized.
The auto setting tells Git to use color whenever it is generating output to be displayed but to render plain text whenever the output is being piped to another process. This makes it easy to output a raw diff—the changes between two versions of the file—to a file but still allows you to see the colorized diff when you view the output directly.
Finally, Git uses core.editor to specify a particular editor. Git launches an editor whenever you need to create a commit message, edit patches, and do a few other tasks.
Git doesn’t require you to set the core.editor value, though. It tries to figure out what editor to use by checking the following values, in order: GIT_EDITOR environment variable; core.editor configuration value; VISUAL environment variable; EDITOR environment variable; and, finally, plain vi.
The value is the command-line script to launch your editor. In Windows, this is a bit tricky, but there’s an excellent thread on Stack Overflow[12] that can help you get started.
What To Do... |
| prompt> git config --global user.name "Your Name" |
| prompt> git config --global user.email "[email protected]" |
| prompt> |
| prompt> cd /path/to/repository |
| prompt> git config user.name "Your Name" |
| prompt> git config user.email "[email protected]" |
| prompt> |
| prompt> git config --global color.ui auto |
| prompt> |
| prompt> git config --global core.editor /path/to/editor |
| prompt> |
18.118.141.27