CheatSnip

Related

Clean Untracked Files

git

Remove untracked files and directories from your working tree to restore a clean workspace

Switch Branches

git

Switch branches or restore files

Add Files

git

Stage file changes to the Git index (staging area) in preparation for committing

git/restore

Restore Files

Restore working tree files (Git 2.23+)

git
restore
files

Command

git restore

Explanation

git restore is used to restore working tree files (Git 2.23+). It restores the working tree files (Git 2.23+).

Examples

Discard unstaged changes

git restore file.txt

Unstage file

git restore --staged file.txt

More

Check Repository Status

git

Display the current state of your working directory and staging area, showing which files are modified, staged, or untracked

Switch Branches (New)

git

Switch branches (Git 2.23+)

Stash Changes

git

Temporarily save your uncommitted changes without committing them, allowing you to work on something else and restore them later

CheatSnip

Lightning-fast access to essential developer commands and code snippets. Search, copy, and master your favorite tools with our comprehensive cheat sheets.

Poorna Prakash

Quick Links

Git CommandsDockerNPMKubernetesYour Favorites

Legal

Terms & ConditionsPrivacy PolicyCookie Preferences

Company

About UsContact

© 2026 CheatSnip. All rights reserved.

Made with ❤️ for developers