Skip to main content

Git for Authors

Section A.2 Configuring Git the First Time

This subsection has some one-time details you need to work through before using git.
First you need to identify yourself as the author of commits. Even if your repository will be private for a while, someday you may open it up to collaborators, and you would rather not go back and edit all of your commits. Fortunately, git makes it easy. Use your real name, and use an email address that you expect to own for a long time. Together, these two pieces of information should identify you across all the repositories you will ever contribute to, and across all the repositories ever made.
rob@lava:~$ git config --global user.name "Robert A. Beezer"
rob@lava:~$ git config --global user.email beezer@pugetsound.edu
Notice that I use different values in practice, rather than the example here. In the earlier days of electronic mail, my institution used the domain name ups.edu, often confusing us with the shipping company, ups.com. So I prefer to use the older form that I was known by in other settings for many years. Notice the quotes around my name, in order to include the spaces as part of the text of my name.
git is inclined to drop you into an editor for various tasks. We try to avoid this, so often show you the -m switch, followed by a short quote-protected message you can supply as part of a command. But you will need to use an editor for various tasks (such as an interactive rebase) so you do not want to suddenly find yourself in a system-default editor (like vi or emacs) that you do not understand. I know the basics of an enhanced version of vi, known as vim, so I use the command-line name of this program in the setting below.
rob@lava:~$ git config --global core.editor vim
There are other settings, and you can check yours with git config --list. One last thing. If your version of git happens to be prior to version 2.0, then check your configurations for the value of push.default and ensure that it is simple. It will be important later.
More details, and especially for Windows systems, can be found in the Pro Git book [3, Section 1.6]