Configuration of Git

We can configure Git both locally and globally. If we want to set ownership for a single repository, we configure it locally. If we want the ownership settings to apply to all repositories on the system, we configure it globally.

Check if Git is installed

Open your terminal (linux/macOS) or GitBash (Windows):

git --version

if installed, you will see something like :

Configure Git Globally

This sets your identity for all repositories on your system.

git config --global user.name "username"
git config --global user.email "[email protected]"

Configure Git Locally

Step 1 : Create a Repository

Make a directory gitproject and navigate to folder and initialize the git repo with command git init.

mkdir gitproject
cd gitproject
git init
creating a gitproject folder
Change the working directory to gitproject
Initialize the git hub repo

if you want to push local repo to GitHub, you can learn from here

Step 2 : Configure the Git locally

  • We can use --local instead of --global in the configuration to configure the git repo locally.

git config --local user.name "username"
git config --local user.email "[email protected]"

View Git Configuration

  • If you want to view Global Configuration, use command :

git config --global --list

it will show you configuration details :

  • If you want to view Local Configuration, navigate the repo folders and run the command :

git config --local --list

Last updated