Basics

Git Configuration

Configuring Git

Git configuration sets user.name and user.email with git config.

Understanding Git Configuration

Git configuration is essential for setting up your identity in a Git repository. This configuration ensures that your commits are attributed correctly with your name and email address. Typically, this setup is a one-time process performed after installing Git on your system.

Setting Up Global Configuration

The global configuration applies your username and email to all repositories on your system. To set these globally, use the git config command with the --global flag.

Repository-Specific Configuration

In some cases, you might want to use different user information for a specific repository. In such scenarios, you can set the user details without the --global option while being inside the desired repository.

Viewing Your Configuration

To verify your configuration, you can use the git config --list command. This command will display all the configuration settings currently applied, including user information and other settings.

Editing Configuration Files Directly

Advanced users can directly edit the configuration files. The global configuration is stored in ~/.gitconfig while the repository-specific configuration is located in .git/config within the repository folder.

Common Issues and Troubleshooting

It's important to ensure that your email is correct, especially if you're contributing to open-source projects, as this will affect your contributions on platforms like GitHub. If you encounter identity-related errors, double-check your configuration using the steps outlined above.