Setting Up Git Using git config (original) (raw)

Last Updated : 16 Jan, 2026

Git configuration helps set up your identity and preferences so Git can track changes correctly and work according to your workflow.

Working of Git Configuration

Steps To Setup Git using Git Config

Step 1: Install git

The first thing you have to do is install git in your system to proceed further. Follow these articles according to your system.

Step 2: Check for git version

Now, if you have successfully installed Git, you can verify and check its version using the following command.

git --version

Step 3: Set global username

Set your name for all repositories using the command

git config --global user.name 'username'

Screenshot-2025-03-03-103913

Set global username

Step 4: Set global email

Set your email for all repositories by using the command

git config --global user.email 'user email'

Screenshot-2025-03-03-104043

Set global email

Step 5: Set local username and email

Set your name for the current repository before that you have to initialize a empty git repository. And then set the username and email.

git init
git config --local user.name 'username'
git config --local user.email 'email'

Screenshot-2025-03-03-104629

Set local username

Screenshot-2025-03-03-104856

Set local email

Step 6: Configuring the Default Branch Name

By default, Git used to initialize repositories with the master branch. You can change this to main or any preferred name.

git config --global init.defaultBranch main

Screenshot-2025-03-03-105843

Set default branch name

Step 7: Create an alias for a command

Git aliases allow you to shorten commonly used commands. Allowing git st instead of git status to work the same

Screenshot-2025-03-03-110545

Create an alias for a command

Step 8: View all configurations

Shows all Git settings that have been made by the current user

git config --list

Screenshot-2025-03-03-110748

View all configurations

Step 9: Removing or Resetting Configurations

If you need to remove or reset any configurations, use:

git config --global --unset user.email

Or reset all settings to default:

rm ~/.gitconfig # For Linux/Mac
del %USERPROFILE%.gitconfig # For Windows