Configuring Git
After installation, there are only a few basic Git configuration options I recommend before jumping in.
User Information
Recall that Git keeps track of author information when it saves code history. To that end, provide Git with your name and email address so it can embed this information in your code commits.
Run the following commands in your terminal to set your personal user information:
git config --global user.name "Your name"git config --global user.email "email@domain.com"The --global flag tells Git to set the provided name and email as the default value for any Git repository on your system. There are other options, such as --local, which sets this information on a per-project basis; however, this is not as commonly used.
Even though you are providing an email address, Git does not use it for anything other than embedding it as plaintext in your code commits. Git does not automatically provide notifications or remote code hosting capabilities out of the box. If you're planning on using a remote code hosting service such as GitHub, you can easily edit configuration options later.
Default Terminal Text Editor
Periodically, when running certain commands, Git will prompt you to edit files. By default, Git will open files for editing in VI, a terminal text editor that can be quite confusing for new programmers. VI is keyboard-only and requires knowledge of special keyboard shortcuts to edit and save files.
In this course, I will walk you through using VI during the times when editing files arises. Using configuration values, you can easily let Git know you'd rather use a different text editor in these circumstances.
VS Code
Ensure you've configured VS Code to launch from the command line. To verify this, run:
code --versionThe output should be something like: 1.80.1. If you see the message "command not found: code", or another similar error message, follow these steps to install the VS Code command line capabilities.
Now, run the following command to tell Git to use VS Code to edit files:
git config --global core.editor "code --wait"Sublime, Notepad++, TextMate, Etc.
For instructions on how to associate other editors with Git, check out this guide.
Verifying Your Configuration
To check that Git has correctly stored your configuration settings, run the following command to list your current settings:
git config --listBehind the scenes, Git stores these configuration settings in a file called .gitconfig, which can typically be found at ~/.gitconfig. You can edit this file directly to change your Git settings, or use the git config command.