DELAPARRA
Index
Color
NL
Category: Git commands

git reset

Explained by Updated

What is git reset?

git reset: Move the branch pointer backwards in history, optionally changing staged/working-directory state. git reset moves your branch back to an earlier commit. How it treats your changes depends on the mode. --soft keeps the changes staged, --mixed, the default, keeps them in your files but unstaged, and --hard throws them away.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about git reset

How is git reset used in practice?

It is useful for undoing local commits before you share them, such as combining your last three commits into one: git reset --soft HEAD~3 followed by a new commit.

What should you keep in mind with git reset?

git reset --hard is one of the few Git commands that can really lose work, because uncommitted changes are deleted. Committed work can usually be recovered through git reflog, which records where your branch pointed before. Never reset commits that are already on a shared branch. Use git revert there, which undoes a change with a new commit instead of rewriting history.

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.