Agentic AI with Java: Live Cohort
GitGit Fundamentals

Git Installation & Initial Configuration


Before you can start using Git, you need to install it and configure your identity. This is a one-time setup that allows Git to track who makes each commit and ensures your development environment is ready for version control.

Installing Git

The installation process varies slightly depending on your operating system, but once installed, Git works the same across all platforms.

Installing Git on macOS

Git is typically available through the Xcode Command Line Tools.

If you have already installed Xcode or its Command Line Tools, Git is likely ready to use without any additional installation.

To verify whether Git is installed, open the Terminal and run:

git --version

If Git is installed, you'll see output similar to:

git version 2.50.1

If Git is not installed, macOS will usually prompt you to install the Command Line Tools automatically.

Installing Git on Windows

Windows does not include Git by default, so you need to install it manually.

Step 1: Download Git

Visit the official Git website:

https://git-scm.com/install/

Choose Windows and download the latest installer.

Step 2: Install Git

Run the downloaded installer and follow the installation wizard.

For beginners, the default installation options are recommended, as they work well for most users.

The installer includes useful tools such as:

  • Git
  • Git Bash
  • Git GUI

Step 3: Verify the Installation

After the installation is complete, open either Command Prompt, PowerShell or Git Bash.

Then execute:

git --version

Example output:

git version 2.50.1

Seeing a version number confirms that Git has been installed successfully.


Understanding Git Configuration

Installing Git is only the first step.

Before making commits, Git needs to know who you are so it can attach your identity to every commit.

Git stores configuration information such as:

  • Your name
  • Your email address
  • Default editor
  • Preferred settings
  • Aliases and other customizations

These settings can be configured globally (for all repositories) or locally (for a single repository).

1. Checking the Installed Git Version

The first command most developers run after installation is:

git --version

Purpose

  • Confirms Git is installed correctly.
  • Displays the currently installed version.
  • Useful for troubleshooting installation issues.

2. Viewing Git Configuration

To see Git's available configuration options, use:

git config --list

This command displays information about Git's configuration system and the available configuration commands.

It is commonly used as the starting point when learning Git configuration.

3. Listing Global Configuration

Git allows you to view all globally configured settings using:

git config --global --list

Purpose

Displays all global Git settings currently stored on your computer.

Typical output may include:

user.name=Muskan Garg
user.email=muskan@example.com
init.defaultBranch=main

These settings are automatically applied to every Git repository you create on your machine.

4. Setting Your Git Username

Every commit records the name of the person who made it.

To configure your name globally, run:

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

Example

git config --global user.name "Muskan Garg"

Why is this important?

Your configured name appears in the commit history.

Example:

Author: Muskan Garg

This allows team members to identify who made each change.

5. Setting Your Git Email Address

Git also records the email address associated with every commit.

Configure it using:

git config --global user.email "your_email@example.com"

Example

git config --global user.email "muskan@example.com"

Why is this important?

Your email serves as your unique identity in Git.

Platforms like GitHub, GitLab, and Bitbucket use this email to associate commits with your account.

Example:

Author: Muskan Garg <muskan@example.com>

If the configured email matches the one registered with your Git hosting platform, your commits will appear under your profile automatically.


Global vs Local Configuration

Git settings can be applied at different levels.

Global Configuration

git config --global
  • Applies to every Git repository on your computer.
  • Typically used for your name and email.
  • Configured only once.

Local Configuration

git config

(without the --global flag, when executed inside a repository)

  • Applies only to the current repository.
  • Overrides global settings for that project.
  • Useful when working on projects that require a different identity.

Example

Suppose you use:

  • Personal GitHub account for personal projects
  • Company GitHub account for office work

You can keep your personal identity globally and configure a different name and email only for your company's repository.

Configure_Git_Identity


Common Git Setup Commands

CommandPurpose
git --versionDisplays the installed Git version
git configShows Git configuration information and available options
git config --listLists all Git configuration settings (system, global, and local)
git config --global --listLists all globally configured Git settings
git config --local --listLists configuration settings for the current repository only
git config --global user.name "Your Name"Sets your username for all repositories
git config --global user.email "your_email@example.com"Sets your email address for all repositories
git config --unset --global user.nameRemoves the globally configured username
git config --unset --global user.emailRemoves the globally configured email
git config --global init.defaultBranch "main"Sets the default branch name for new repositories

Summary

  • Git must be installed before you can use version control.
  • Use git --version to verify that Git has been installed successfully.
  • Git records the author's name and email with every commit.
  • Global configuration applies to all repositories on your computer.
  • Local configuration affects only the current repository and overrides global settings when needed.
  • Setting the correct email helps platforms like GitHub associate your commits with your account.

Written By: Muskan Garg

How is this guide?

Last updated on