All tools

Git Cheatsheet

Development

Quick-reference guide to everyday Git commands for branching, rebasing, stashing, and recovery.

Configuration

Set global author name
git config --global user.name "[name]"
Set global author email
git config --global user.email "[email]"

Get Started

Create a new git repository
git init
Clone an existing repository
git clone [url]

Commit & Amend

Commit all tracked changes
git commit -am "[message]"
Add modifications to last commit
git commit --amend --no-edit
Change last commit message
git commit --amend

Undo & Reset

Undo last commit and keep changes
git reset HEAD~1
Undo last commit and discard changes
git reset HEAD~1 --hard
Reset branch to remote state
git fetch origin && git reset --hard origin/[branch]
Rename master branch to main
git branch -m master main