Installation

Linux

sudo apt install git-all

Windows

Chocolatey

Install chocolatey
Run powershell as admin

choco install git -y

Winget

winget install --id Git.Git -e --source winget

Usage

# Initialize a new Git repository
git init
# Download a .gitignore template 
# Templates : https://github.com/github/gitignore
curl -o .gitignore <template-url>
# Add a submodule
git submodule add <repository> [<path>]
# Configure commit user
git config user.name <name>
git config user.email <email>
# Sign commits with SSH
# Linux Default : ~/.ssh/id_ed25519.pub 
# Windows Default : C:/Users/User/.ssh/id_ed25519.pub 
git config commit.gpgsign true 
git config gpg.format ssh 
git config user.signingkey <public-key>
# Stage and commit
git add -A 
git commit -m "Initial commit"   
# Rebase current working branch with main
git rebase main
# Reset current branch using main branch as reference
git reset --hard origin/main
# Discard local changes recursively
git clean -df
# Remove any local branches or tags that no longer exist on the remote
git fetch --prune --prune-tags
# List local branches that doesn't exist on the remote
git branch -vv | grep ': gone' | awk '{print $1}'
 
# Delete local branches that doesn't exist on the remote
git branch -vv | grep ': gone' | awk '{print $1}' | xargs git branch -d

Notes

Mutiple References

If you encountered error below

error: src refspec <branch-name> matches more than one

Start by checking references

git show-ref <branch-name>

And then cleanup references

git push --delete origin <reference-name>
git push origin :<reference-name>

Appendix