1. Repositories Management & Remote Tracking
git remote -vWhat it doesDisplays the names and addresses of registered remote repositories (fetch and push)
When to use itto check the remote link before uploading or fetching
Example
git remote -vgit branch -M mainWhat it doesRenames the current branch to main as the default GitHub-compatible branch name
When to use itWhen initializing a new repository and converting master to main
Example
git branch -M maingit push -u origin mainWhat it doesUploads the local branch to the remote repository and sets upstream tracking
When to use itOn the first master branch push to GitHub
Example
git push -u origin maingit rm --cached <file>What it doesRemoves the file from the Staging index but keeps it on the local storage disk
When to use itWhen you accidentally add a sensitive file and want to include it in .gitignore without deleting it
Example
git rm --cached .envgh repo viewWhat it doesDisplays a summary of the current repository from the command line (description, stars, and default branch)
When to use itTo quickly view repository details without opening the browser
Example
gh repo viewgh repo view --webWhat it doesOpens the current repository page directly in the default web browser
When to use itto jump directly to the GitHub interface in the browser
Example
gh repo view --web