Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Changes

STAGE

Stage all changes

git add .

Stage changes in interactive mode

git add -i

Stage changes in patch mode

git add -p

UNSTAGE

Unstage some changes (MOVE from Index (staging area) to Workspace)

new

git restore --staged <file>

old

git reset <file>
git reset HEAD <file>

Unstage all changes

new

git restore --staged .

common

git reset

old

git reset HEAD

DELETE

Delete changes in Workspace

new

git restore <file>

old

git checkout -- <file>
git checkout <file>

Delete all changes in Workspace

new

git restore .

old

git checkout .

Delete all changes in Index and Workspace

git reset --hard
git reset --hard HEAD

REMOVE FROM GIT

Remove file from Git tracking but keep it on disk

git rm --cached <file_name>

Remove file from the git repository and from the local disk

git rm <file_name>