Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
Git

Git Reset vs. Revert vs. Rebase: What Each Changes and When to Use It

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

git reset moves the current branch tip, git revert records a new commit that undoes an earlier change, and git rebase replays commits on a different base. The practical choice hinges on two questions: has the work already been shared, and do you want to rewrite commit history or preserve it?

For work already shared publicly, prefer git revert. Use reset or rebase to change local history when that rewrite is intentional and coordinated. These commands change different parts of repository state; they are not interchangeable.

At a glance: what changes?

Command Main effect Effect on history Typical use
git reset Moves the current branch tip; the mode determines whether the index and working tree also change. Its path form updates selected index entries only. Changes the branch tip and can remove commits from that branch’s visible history. Undo or regroup local commits; unstage selected files.
git revert Applies the inverse of a commit’s changes and records the result in a new commit. Keeps the original commit and adds an undo commit. Undo a change that has already been shared.
git rebase Replays a sequence of commits on another base. Interactive mode can reorder or combine commits. Rewrites the replayed commits. Update a local topic branch or edit a local commit series.

The Git Project’s overview distinguishes reset, which updates a branch by moving its tip, from revert, which makes a new commit that reverses earlier changes: Git documentation. The separate operations can affect different repository states: branch pointer, index (staging area), working-tree files, and commit history.

What does git reset do?

A commit names a point in history. Running git reset <commit> moves the current branch’s HEAD to that selected commit. Whether your staged and unstaged changes remain depends on the mode. This is usually a local-history tool: the commits beyond the new tip are no longer on that branch.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

--soft: move the tip, keep everything staged

git reset --soft HEAD^ moves the branch tip back one commit but leaves both the index and working tree alone. Use it when a recent local commit should be removed as a commit while its changes remain staged—for example, so you can correct the commit before making it again.

--mixed: move the tip and unstage changes

git reset --mixed HEAD^ moves the tip back one commit and resets the index to match that target, but leaves working-tree files alone. The changes from the removed commit remain in your files as unstaged edits. --mixed is the default mode, so git reset HEAD^ has the same reset mode.

--hard: reset the tip, index, and working tree

git reset --hard <commit> makes the branch tip, index, and working tree match the target commit. It can discard tracked working-tree changes. Do not use it as a casual undo or while valuable uncommitted work is at risk. The Git 2.53.0 reset manual describes each mode and cautions against resetting commits after giving them to someone else.

Path form: unstage without moving the branch

git reset <path> is different from resetting to a commit: it updates the selected index entries and does not move HEAD or change working files. For example, git reset -- src/app.js unstages that file while leaving its edits in place. The newer corresponding interface is git restore --staged <path>, such as git restore --staged -- src/app.js.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What does git revert do?

git revert <commit> applies the inverse of the selected commit’s change and records that result as a new commit. The old commit stays in history; the branch advances to include the compensating commit. That makes revert the usual choice when teammates or other users may already have based work on the original commit.

For example, to undo the change introduced by commit abc1234, run git revert abc1234. Review the resulting change before sharing it. A revert is not a time machine: it adds a new change that counteracts an earlier one, and later overlapping edits can make the inverse conflict with the current files.

Reverting a merge commit

A merge has more than one parent, so reverting it requires specifying which parent is the mainline with -m. For example, git revert -m 1 <merge-commit> selects parent 1 as the mainline; use that only when it is the parent whose line of development should be retained. Check the merge’s parents and intended result before choosing. A merge revert also affects what later merges bring in, so it is not a routine substitute for reverting an ordinary commit. See the Git revert manual.

What does git rebase do?

Rebase takes a sequence of commits and replays them on another starting point. In everyday terms, it can move a local topic branch’s work so it appears on top of a newer base. The changes may be similar, but replaying creates rewritten commits; do not assume their original commit IDs remain the same. The Git 2.53.0 rebase manual describes the operation as transplanting commits to a different starting point.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Interactive rebase lets you edit a local series—for instance, reorder or combine commits. That changes the history other people would see if the old series had already been shared. Use it when you intend to rewrite that series, not as a way to quietly update a public branch.

Handling rebase conflicts

If a replay conflicts, resolve the affected files to the intended content, stage the resolutions, then run git rebase --continue. To abandon the in-progress rebase and return to the pre-rebase state, run git rebase --abort. Do not continue until the staged resolution is what you want.

Which command should you choose?

  • The commit is local, and you want to remove it but keep its changes staged: use git reset --soft HEAD^.
  • The commit is local, and you want its changes left in files but unstaged: use git reset --mixed HEAD^, or the default git reset HEAD^.
  • You only want to unstage a file: use git restore --staged <path> or the path form git reset <path>; neither moves the branch tip.
  • The commit has been shared: use git revert <commit> to add a compensating commit rather than moving the shared branch tip backward.
  • You want to move your local commits onto a different base or reshape a local series: use git rebase when rewriting those commits is acceptable.
  • You are considering reset --hard: first inspect repository state and preserve work you may need; the command updates both index and working files to match its target.

The Git User Manual says to make a new undo commit for a mistake that has been made public and warns, “You should never do this if you have already made the history public,” in its discussion of rewriting history: Git User Manual. Teams may coordinate a rewrite, but absent that deliberate agreement, a new revert commit avoids making collaborators reconcile a changed public history.

Check state before changing history

Before reset or rebase, inspect the repository so you know what is staged, what is only in the working tree, and which commits are on the branch. Preserve valuable uncommitted work before any operation that may replace files or rewrite commits. A command that is right for the commit graph can still be wrong for your unstaged edits.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Run git status to inspect staged and unstaged changes.
  2. Run git log --oneline --decorate -n 10 to inspect recent commits and the current branch position.
  3. Choose the operation based on whether the commit is shared and whether you want to move the branch tip, record an inverse commit, or replay commits.
  4. After resolving any conflict, inspect the staged and working-tree changes before continuing or completing the operation.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common problems and how to recover

“I reset, but my changes are still here”

That can be the intended result. A soft reset leaves the index and working tree unchanged; a mixed reset leaves working-tree edits but unstages them. Check git status and use the mode whose effect matches what you want.

“I used --hard and files changed unexpectedly”

--hard makes the index and working tree match the target commit, so tracked edits can be lost from the working tree. Before using it, inspect status and preserve any work you might need. Do not treat it as equivalent to a soft or mixed reset.

“Revert or rebase stopped on a conflict”

Resolve the conflict in the affected files, stage the intended result, then follow the operation-specific control: git rebase --continue for a rebase, or continue the revert sequence after staging its resolution. If you need to abandon a rebase, use git rebase --abort. Revert also has continuation and abort controls; consult its manual for the options applicable to the invocation: git-revert.

“I need to undo a merge”

Do not select a mainline parent by guesswork. Identify the merge’s parents and intended retained line first; -m tells Git which parent is the mainline. Because a merge revert influences later merges, consider the effect on future integration before committing it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A separate developer utility: ScreenshotNeo

ScreenshotNeo is not a Git history tool and does not change the reset, revert, or rebase decision. It is a separate website screenshot API and MCP server for developers. If your workflow also needs website captures, ScreenshotNeo offers one-call captures and an MCP server for AI agents.

For example, this cURL request captures a URL; parameter and response details are in the ScreenshotNeo documentation:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Cookie banners, popups, and chat widgets are removed before the shot; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for 1,000 free screenshots a month, with no card required.

Frequently Asked Questions

Can I use reset to unstage a file without changing its contents?

Yes. Use the path form, such as git reset -- src/app.js, or git restore --staged -- src/app.js. Both leave the working-tree edit in place.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Does reverting a commit erase it from history?

No. Revert records a new commit that applies the inverse change; the original commit remains in the history.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.