GIT Practical Reference

Configuring Git

Set Git username and email

In Git, configuring your identity is crucial for tracking who made specific changes in a Git repository.

To set your global username and email for all your Git repositories on the current machine, open your terminal and run the following commands:

git config --global user.name "Your Name"

git config --global user.email youremail@example.com

To set your username and email for a specific repository only, remove the --global flag and run the commands inside the repository directory:

git config user.name "Your Name"

git config user.email [email protected]

To verify that your configuration changes have been applied, you can use the following command to display your Git configuration:

git config --list

Set Default Branch Name

You can specify the default branch name for new repositories. For example, to globally set the default branch name to 'main' instead of 'master', use:

git config --global init.defaultBranch main

This change ensures that new repositories start with the 'main' branch.