Installation
Linux
sudo apt install git-allWindows
Chocolatey
Install chocolatey
Run powershell as admin
choco install git -yWinget
winget install --id Git.Git -e --source wingetUsage
# 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 -dNotes
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>