Skip to main content

Python input() Function

Imagine you are creating a calculator in Python. Instead of writing numbers directly inside the program, you want the user to enter two numbers and let the program calculate their sum. Or suppose you want to create a student registration program that asks for a student's name, age, roll number, and marks. How can a Python program receive information from a user? Python provides a built-in function called input() for this purpose. The input() function allows a program to pause, accept information entered by the user, and store that information in a variable. In this article, we will learn how to use input() with simple examples, understand why it returns a string, convert user input into numbers, and build a practical calculator program. 1. What Is the input() Function in Python? The input() function is a built-in Python function used to accept information from the user. When Python encounters an input() statement, it displays an optional message called a prompt and waits for ...

Understanding Git Configuration: Global, Local, and System Settings Explained

After installing Git, the first thing every developer should do is configure it.

Many beginners simply copy and paste the following commands without understanding what they actually do:

git config --global user.name "John Doe"

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

These commands work, but understanding why they are needed is far more important.

Every time you create a commit, Git records information about the author, the time of the commit, and many other settings. These settings are stored in Git's configuration files.

Git allows configuration at three different levels:

  • System

  • Global

  • Local

Each level has a different purpose and priority.

In this article, you will learn how Git stores configuration, how to view and modify settings, and how Git decides which configuration to use.


What is Git Configuration?

Git configuration is the collection of settings that control how Git behaves.

These settings tell Git things like:

  • Your name

  • Your email address

  • Which text editor to use

  • Which default branch to create

  • How colors should appear

  • Which merge strategy to use

  • How credentials should be stored

Without configuration, Git cannot properly identify who created a commit.


Why Does Git Need Your Name and Email?

Every commit in Git contains metadata.

Metadata is information about the commit.

For example:

Commit ID:
9d45f78...

Author:
Rahul Sharma

Email:
rahul@gmail.com

Date:
15 July 2026

Message:
Added Login Feature

Git stores the author's identity permanently inside every commit.

This allows teams to know:

  • Who made the change?

  • When was it made?

  • Which commit introduced a feature or bug?


The Git Configuration Hierarchy

Git stores configuration in three levels.

System Configuration
        ↓
Global Configuration
        ↓
Local Configuration

When Git looks for a setting, it checks them in the following order:

  1. Local

  2. Global

  3. System

The first matching setting is used.


1. System Configuration

System configuration affects every user on the computer.

It is mainly used by:

  • System administrators

  • Organizations

  • Shared computers

Typical examples:

  • Company-wide Git editor

  • Corporate proxy settings

  • Default merge tools

System configuration is rarely changed by beginners.


Location

Windows

C:\Program Files\Git\etc\gitconfig

Linux

/etc/gitconfig

macOS

/usr/local/etc/gitconfig

View System Configuration

git config --system --list

Administrator privileges may be required.


2. Global Configuration

Global configuration is the most commonly used level.

It applies only to your user account.

Every repository you create automatically uses these settings unless overridden locally.

Most developers configure Git globally once and rarely change it.


Examples

Your name

git config --global user.name "Rahul Sharma"

Your email

git config --global user.email "rahul@gmail.com"

Default editor

git config --global core.editor "code --wait"

Enable colors

git config --global color.ui auto

Global Configuration File

Windows

C:\Users\Username\.gitconfig

Linux/macOS

~/.gitconfig

3. Local Configuration

Local configuration applies only to one repository.

Every Git repository has its own local configuration.

This allows different projects to have different settings.


Example

Suppose you work for two companies.

Company A uses:

rahul@companyA.com

Company B uses:

rahul@companyB.com

Instead of changing your global email every time, you can configure each repository separately.

Inside Company A's project:

git config user.email "rahul@companyA.com"

Inside Company B's project:

git config user.email "rahul@companyB.com"

Each repository remembers its own configuration.


Local Configuration File

Every repository contains:

.git/config

This file stores repository-specific settings.


Configuration Priority

Suppose Git finds the following email addresses:

System:

admin@company.com

Global:

rahul@gmail.com

Local:

rahul@office.com

When you make a commit inside that repository, Git uses:

rahul@office.com

because Local has the highest priority.


Viewing Git Configuration

Display All Settings

git config --list

Example output:

user.name=Rahul Sharma
user.email=rahul@gmail.com
core.editor=code --wait
color.ui=auto

View Only Your Name

git config user.name

View Only Email

git config user.email

View Global Name

git config --global user.name

View Local Name

git config --local user.name

Setting Your Name

git config --global user.name "Rahul Sharma"

Git stores this name inside every commit.


Setting Your Email

git config --global user.email "rahul@gmail.com"

Always use the email linked to your GitHub account if you plan to push code to GitHub.


Changing Configuration

Changing your name is simple.

git config --global user.name "Amit Kumar"

The previous value is replaced.

The same applies to your email.


Removing Configuration

You can remove settings if they are no longer needed.

Example:

git config --global --unset user.email

Similarly:

git config --global --unset user.name

Listing Configuration Sources

Sometimes you may want to know where each setting comes from.

Run:

git config --list --show-origin

Example output:

file:C:/Users/Rahul/.gitconfig
user.name=Rahul Sharma

file:C:/Users/Rahul/.gitconfig
user.email=rahul@gmail.com

This helps identify whether a setting comes from the System, Global, or Local configuration.


Common Configuration Options

Default Editor

Visual Studio Code

git config --global core.editor "code --wait"

Vim

git config --global core.editor "vim"

Nano

git config --global core.editor "nano"

Enable Colored Output

git config --global color.ui auto

Colored output makes Git messages easier to read.


Default Branch Name

git config --global init.defaultBranch main

Every new repository will now start with the main branch.


Credential Storage

Store credentials securely:

git config --global credential.helper manager

Windows users commonly use Git Credential Manager.


Common Beginner Mistakes

Mistake 1

Using the wrong email address.

Always use the email associated with your GitHub account if you want your commits to appear under your GitHub profile.


Mistake 2

Typing --global inside a repository when you only want to change that specific project.

Remember:

  • --global affects all repositories.

  • No flag (inside a repository) affects only the current repository.


Mistake 3

Editing .gitconfig manually without understanding the syntax.

Use Git commands whenever possible.


Best Practices

  • Configure your name and email immediately after installing Git.

  • Use your real name for professional projects.

  • Keep one global configuration for personal work.

  • Use local configuration for company or client repositories if needed.

  • Use git config --list regularly to verify your settings.


Summary

Git configuration controls how Git behaves and how it identifies you as a developer. Git stores settings at three levels: System, Global, and Local. The Local configuration has the highest priority, followed by Global and then System.

Most developers only need to configure their Global settings once, but Local configuration is useful when working on projects that require different identities or custom settings.

Understanding Git configuration is essential because every commit you create includes the information defined by these settings.


Frequently Asked Questions (FAQs)

1. What is Git configuration?

Git configuration is a set of settings that control Git's behavior, such as your name, email, editor, and default branch.

2. Which configuration level has the highest priority?

Local configuration has the highest priority, followed by Global and then System.

3. Where is Global configuration stored?

In the .gitconfig file inside your user profile directory.

4. Can I use different email addresses for different projects?

Yes. Configure different email addresses using Local configuration inside each repository.

5. How can I see all my Git settings?

Run:

git config --list

Comments

Popular posts from this blog

Understanding Comments in Java: A Beginner’s Guide

When learning Java programming, one of the first concepts you’ll come across is comments . Comments may not affect how a program runs, but they play a crucial role in making code more understandable, readable, and maintainable. Let’s dive deeper into what comments are, why they’re important, and the different types of comments in Java. What are Comments in Java? A comment in Java is a piece of text written within a program that is ignored by the compiler . In other words, comments are notes for humans, not instructions for machines. They help developers explain the purpose of code, describe logic, or temporarily disable certain lines of code without deleting them. Why are Comments Important? 📌 Readability – Comments make code easier to understand for you and others. 📌 Maintenance – When you revisit your code after months, comments remind you what you were doing. 📌 Collaboration – In team projects, comments explain code to fellow developers. 📌 Debugging – You c...

Java Program to Check Voting Eligibility

In this program, we’ll take the user’s age as input and check whether the person is eligible to vote or not. In India, the minimum age required to vote is 18 years . 💻 Program Code // Java Program to Check Voting Eligibility import java.util.Scanner; public class VotingEligibility { public static void main(String[] args) { // Create Scanner object to take input from user Scanner sc = new Scanner(System.in); // Ask user to enter age System.out.print("Enter your age: "); int age = sc.nextInt(); // Check eligibility if (age >= 18) { System.out.println("You are eligible to vote."); } else { System.out.println("You are not eligible to vote yet."); System.out.println("You can vote after " + (18 - age) + " year(s)."); } sc.close(); // Close the scanner } } 🧠 Explanation import java.util.Scanner; → Imp...

Java Program to Calculate Total Marks and Average of Five Subjects

💡 Program Explanation In this program: The user will input marks of five subjects . The program will calculate the total marks and average . It will then display both results clearly. 🧑‍💻 Java Code: // Java Program to Calculate Total Marks and Average of Five Subjects import java.util.Scanner; // Importing Scanner class for user input public class TotalAndAverage { public static void main(String[] args) { // Creating Scanner object to take input from user Scanner sc = new Scanner(System.in); // Declaring variables for five subjects double subject1, subject2, subject3, subject4, subject5; // Taking marks input for each subject System.out.print("Enter marks of Subject 1: "); subject1 = sc.nextDouble(); System.out.print("Enter marks of Subject 2: "); subject2 = sc.nextDouble(); System.out.print("Enter marks of Subject 3: "); subject3 = sc.nextDo...