Essential Commands of Git & GitHub for Devops, and Different between Git & Github.
Configuring User Information Across All Repositories
1. Set Your Username
$ git config --global user.name "Shahrukh Ahmad"
2. Set Your Email Address
$ git config --global user.email "[abc@example.com"
](mailto:abc@example.com)3. heck Your Configuration
$ git config --global --list
4. Update or Remove Configuration (if needed)
$ git config --global --replace-all user.email "xyz@example.com"
5. Remove User Configuration
$ git config --global --unset-all user.email
Initialize, Clone, Set Up Remote, and Push Changes
1. Initialize a New Repository
Navigate to Your Project Directory
$ cd /path/to/your/project
Initialize the Repository
$ git init
Add All Files to the Staging Area
$ git add .
Commit the Initial Set of Files
$ git commit -m "Initial commit"
2. Clone an Existing Repository
Clone a Repository
$ git clone [lnkd.in/gPDYwG_W
](lnkd.in/gPDYwG_W)Navigate into the Cloned Repository
$ cd repository-name
3. Set Up Remote Repository
Add a Remote Repository
$ git remote add origin [lnkd.in/gPDYwG_W
Verify](lnkd.in/gPDYwG_WVerify) the Remote URL
$ git remote -v
4. Push Changes to GitHub
$ git push -u origin main
1. Checking Status of Your Files
$ git status
2. Adding Files to Staging Area
$ git add index.html
3. Unstaging Files
$ git reset index.html
4. Viewing Unstaged Changes
$ git diff
5. Viewing Staged Changes
$ git diff --staged
6. Committing Your Changes
$ git commit -m "Add new feature to the homepage"
Git Branching & Merging:-
1. Listing Branches
$ git branch
2. Creating a New Branch
$ git branch feature-new-design
3. Switching Between Branches
$ git checkout feature-new-design
4. Merging Branches
$ git merge feature-new-design
5. Viewing Commit History
$ git log
Git Share & Update: Keep Your Re[positories in Sync
1. A](lnkd.in/gKiCmAsT)dding a Remote Repository
$ git remote add origin [lnkd.in/gKiCmAsT
2](lnkd.in/gKiCmAsT2). Fetching Branches from a Remote Repository
$ git fetch origin
3. Merging a Remote Branch into Your Local Branch
$ git merge origin/main
4. Pushing Local Commits to a Remote Repository
$ git push origin main
5. Pulling and Merging Updates from a Remote Repository
$ git pull
Git Tracking: Handling File Removals and Path Changes
1️. Removing a File from the Project
$ git rm old-file.txt
2. Moving or Renaming a File
$ git mv [existing-path] [new-path]
3. Viewing Path Changes in Commit Logs
$ git log --stat -M