top of page

Managing Git Configurations

Objective: The objective of this assignment is to learn how to manage Git configurations. Git configurations allow you to customize the behavior of Git on your system. This assignment will help you practice setting global, local, and repository-specific Git configurations.


ou need to configure Git settings, such as your username, email, and aliases for commonly used commands.


Prerequisites: Before starting this assignment, ensure that you have Git installed on your computer. If not, please install it from [https://git-scm.com/](https://git-scm.com/).


Instructions:


Part 1: Setting Global Configuration


1. Open your terminal or command prompt.


2. Use the following Git command to set your global Git username and email address:


   

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

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

   


   Replace `"Your Name"` and `"your.email@example.com"` with your actual name and email address.


Part 2: Viewing Global Configuration


1. Use the following Git command to view your global Git configuration:


   

   git config --global --list

   


   - This command will display your configured name and email.


Part 3: Setting Local Configuration


1. Navigate to an existing Git repository on your computer or create a new one.


2. Use the following Git command to set a local Git username and email address for the current repository:


   

   git config user.name "Your Repository Name"

   git config user.email "repository.email@example.com"

   


   Replace `"Your Repository Name"` and `"repository.email@example.com"` with your desired repository-specific name and email address.


Part 4: Viewing Local Configuration


1. Use the following Git command to view the local Git configuration for the current repository:


   

   git config --list

   


   - This command will display your repository-specific name and email.


Part 5: Setting Repository-Specific Configuration


1. Navigate to an existing Git repository on your computer or create a new one if you haven't already.


2. Use the following Git command to set a repository-specific configuration:


   

   git config <configuration-key> "Configuration Value"

   


   Replace `<configuration-key>` with the configuration key you want to set (e.g., `core.editor`, `color.ui`, etc.), and `"Configuration Value"` with the desired value.


Part 6: Viewing Repository-Specific Configuration


1. Use the following Git command to view the repository-specific configuration for the current repository:


   

   git config --local --list

   


   - This command will display the repository-specific configuration options and values.

Solutions

Part 1: Setting Global Configuration



# Set global Git username

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


# Set global Git email address

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



Part 2: Viewing Global Configuration



# View global Git configuration

git config --global --list



Part 3: Setting Local Configuration



# Set local Git username for the current repository

git config user.name "Your Repository Name"


# Set local Git email address for the current repository

git config user.email "repository.email@example.com"



Part 4: Viewing Local Configuration



# View local Git configuration for the current repository

git config --list



Part 5: Setting Repository-Specific Configuration



# Set repository-specific Git configuration

git config <configuration-key> "Configuration Value"



Part 6: Viewing Repository-Specific Configuration



# View repository-specific Git configuration for the current repository

git config --local --list


bottom of page