DELAPARRA
Index
Color
NL
Category: Git commands

git restore

Explained by Updated

What is git restore?

git restore: Discard changes in the working directory or unstage files (modern replacement for part of git checkout). git restore discards changes to files or unstages them. git restore config.php throws away your uncommitted changes to that file, and git restore --staged config.php removes it from the staging area while keeping your edits.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about git restore

How is git restore used in practice?

It was introduced to take over the file-related jobs of git checkout, with clearer names and fewer surprises. You can also restore a file from another commit: git restore --source=HEAD~2 config.php.

What should you keep in mind with git restore?

Remember that discarded working changes are gone for good; Git never stored them. Run git diff on the file first if you are not sure what you would lose. If you only want to put changes aside for a moment, git stash is the safer choice, because you can bring them back later.

At a glance

CategoryGit commands
Explained by
Updated

More Git commands terms

All terms starting with G

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.