One day, when I opened SourceTree to submit the code and push it as usual, I suddenly realized that I was just following muscle memory and I had no idea what was going on. This is a very serious problem. As a technician, I was only satisfied with using tools without exploring the principle of tools, so I had a profound reflection.

I think a knowledgeable person should not only know how it is, but also know why it is. Therefore, I will study Git seriously and explore the principle behind Git.

Note: This is all done on OS X, and I highly recommend doing it, playing around, and exploring

Configuration information

I believe this is the first step for everyone to configure their name and email:

$ git config --global user.name "iroyzhang"$git config --global user.email [email protected] $git config --global user.email [email protected] Git config --global --list Configuration is only required once on each computer, and the configuration information is retained when the program is upgraded and can be changed again at any time2 by running commands. This information is used by every Git commit and written to every commitCopy the code

The configuration file

Git config must have saved the configuration information somewhere. Git config must have saved the configuration information somewhere.

$ cd~ // Go to the current user directory-aGitconfig $open -t. Gitconfig $open -t. Gitconfig Git config: git config can be used to read and write configuration files. Git config can be used to read and write configuration files. Git config --gloabl --unset user.name git config --gloabl --unset user.nameCopy the code

– global role

A computer can have multiple users, and if these users are different people, they must have different names and email addresses, so each user needs to customize their Git configuration environment:

Press the following to enter: $git config displays all git config options, including a set of categories called config file Location. --gloabl, --system, --local --global // Use the global configuration file --system // use the system configuration file --local // use the warehouse configuration file Config file Git config --list git config --list git config --list git config --list Variable information may duplicate the extension command: githelpConfig // View config help, Git config --local --list git config --system --list git config --system --list Check your system's common Git configuration. -- the system configuration file is in the root directory, that is, /etc, and the file name is gitconfig. 2.-- the local configuration file is config in the. Git directory of the current working directory. The global configuration file has a higher priority than the system configuration file 4. Git config --local is used as the default git config option. The git configuration information can be modified arbitrarilyCopy the code

Modify the text editor

Git commit $git config --global core.editor $git config --global core.editor If no text editor is specified, Git uses the system default text editorCopy the code