Suggest an editImprove this articleRefine the answer for “What is the difference between git restore and git reset?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)**`git restore`** undoes changes in files and the staging area without touching the commit history, while **`git reset`** moves the branch pointer and can rewrite history. **Key point:** `git restore` works only with files, while `git reset` works with commits and branch state.Shown above the full answer for quick recall.Answer (EN)Image`git restore` and `git reset` are both used to undo changes, but they work **at different levels and with different consequences**. --- ## `git restore` - rolling back files `git restore` is intended **only for working with files**. What it does: - undoes changes in the working tree - removes files from the staging area (unstage) - **does not work with the commit history** - **does not change history** Examples: ```bash git restore file.txt # roll back a file in the working directory git restore --staged file.txt # remove a file from the staging area ``` Used when you need to: - undo local changes in a file - remove a file from the index before a commit --- ## `git reset` - rolling back state and history `git reset` works **with the branch pointer and commits**. What it does: - moves the branch pointer (HEAD) - can change the staging area - can change the working directory - **can rewrite history** Modes: ```bash git reset --soft # changes only the history git reset --mixed # history + staging area (default) git reset --hard # history + staging area + working directory ``` Used when you need to: - undo a commit - roll a branch back - completely remove changes --- ## The key difference | Criterion | git restore | git reset | |---|---|---| | Works with files | Yes | Partly | | Works with commits | No | Yes | | Changes history | No | Yes | | Safe for public branches | Yes | No | | Main purpose | undoing changes | rolling back state | --- ## Short phrasing for an interview > `git restore` is used to undo changes in files and the staging area without changing history. > `git reset` is used to roll back commits and the branch state, and it can rewrite history.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.