GIT
  • What is a Version Control System ?
    • How Software would have been developed before '70s?
    • Expectations of a tool
    • Generation of Version Control System
    • The BitKeeper-Git-Mercurial Saga : How a License Agreement Change Shaped the Open-Source World
    • Mercurial was invented by andrew, then why Linus needs to create GIT
  • Git Installation and Initial Configs
  • Basic Terminologies
  • Q1 - Initialize a Repository and Basic Configurations
  • Q2 - Adding and Staging Files
  • Ways to Exclude Files in GIT ?
Powered by GitBook
On this page
  • Problem Statement
  • Solution

Q1 - Initialize a Repository and Basic Configurations

Problem Statement

  • Initialize a Repository Create a new Git repository in a folder named MyProject. This initializes a .git folder where Git will track changes. Verify the repository is initialized using git status.

  • Set Up User Details Globally Configure your Git setup by setting your global username as DevUser and email as devuser@example.com. This ensures all commits made by you are attributed correctly across all repositories.

  • Set Up Project-Specific User Details Override the global Git configuration for a specific project. Set ProjectUser as the username and projectuser@example.com as the email to track contributions differently in that project.

  • Check Configuration Display all Git configuration details to ensure setup correctness. Use git config --list and filter only the user settings for clarity.

Solution

1. Initialize a Repository

  1. Open a terminal and navigate to the folder where you want to create the repository

mkdir MyProject
cd MyProject
  1. Initialize the Git repository

git init

This creates a .git folder in the MyProject directory.

  1. Verify that the repository is initialized

git status

You should see a message like,

On branch main
No commits yet
nothing to commit, working tree clean

2. Set Up User Details Globally

  1. Set global username and email

git config --global user.name "Syed Jafer"
git config --global user.email "contact.syedjafer@gmail.com"
  1. Verify the global configuration is updated

git config --global --list
PreviousBasic TerminologiesNextQ2 - Adding and Staging Files

Last updated 6 months ago