git init
initialises current repository for git
git add README.md
adds README.md file
git commit -m "<initial commit>"
commit staged changes with message initial commit
git branch -M main
creates local branch named main
git remote -u add origin <remote-git-repository-url>
adds a remote origin to current git repository
git push -u origin main
pushes committed changes to remote origin repository
git help <command>
displays help for specified command
git config --global init.defaultBranch <branch-name>
configures the initial branch name to use in all of new repositories
git branch
shows all local branches
git branch -a
shows all local and remote branches that (local) Git knows about
git branch <branch-name>
creates specified branch locally
git branch -m <branch-name>
renames just created branch
git checkout <branch-name>
switches to specified branch
git push -u origin <branch-name>
pushes specified branch (mostly newly created local branch) to remote
git remote update origin --prune
updates the local list of remote branches
git branch -d <local-branch-name>
deletes local branch
git branch -D <local-branch-name>
deletes local branch with un-merged and un-pushed changes
git push origin --delete <remote-branch-name>
deletes remote branch
git status
shows all local changed files
git stash list
lists all stashes
git stash pop stash@{0}
un-stashes/pops first stash in stack
git stash save "<stash-message-or-name>"
un-stashes/pops first stash in stack
git add
adds...
git add .
adds all local changed files
git commit -m "<commit-message>"
commits locally with specified commit message
git commit --amend -m "<new-commit-message>"
amends most recent un-pushed commit message (all staged changes will also be committed)
git push origin <remote-branch-name>
pushes locally committed changes to remote branch
[Official] Git Reference Manual
[Official] Pro Git Book