- Building Enterprise JavaScript Applications
- Daniel Li
- 251字
- 2021-07-23 16:30:58
Configuring a user
When we ask Git to take a snapshot of our code (also called committing), Git will record several pieces of information, such as the time and author of the commit. The information about the author is saved as Git configurations, which saves us from having to re-type them each time we commit.
By default, adding/updating the configuration would write to the local config file. However, since you are going to be the only person using your user account on your machine, it's better to set the user settings in the global configuration file:
$ git config --global user.name "Daniel Li"
$ git config --global user.email "dan@danyll.com"
This will cause future commits to be, by default, identified as "Daniel Li" whose email address is "dan@danyll.com".
We have now successfully set up Git and configured our user.
For the remainder of this chapter, we will use dummy files to illustrate how Git works and the workflow we will follow. Everything you do for the rest of this chapter should be viewed as an educational exercise, and can be discarded afterward. At the beginning of the next chapter, we will start our project again from scratch, and you will use the things you learned in this chapter to keep your code base's history organized!