Suggest an editImprove this articleRefine the answer for “What does the git reset command do?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)`git reset` moves the branch pointer (HEAD) to another commit and, depending on the mode (--soft, --mixed, --hard), updates the staging area and the working tree. **Key point:** git reset rewrites history, so it is safe to use only for local, unpublished commits.Shown above the full answer for quick recall.Answer (EN)Image`git reset` changes the state of the repository by **moving the branch pointer (HEAD)** and, depending on the mode, updating the **staging area** and the **working tree**. --- ## Main purpose `git reset` is used for: - undoing commits - rolling a branch back to a previous commit - changing the state of the staging area - (in hard mode) fully removing changes --- ## How `git reset` works The command always: - moves the current branch pointer to the specified commit Additionally, depending on the mode, it can: - update the staging area - update the working directory --- ## `git reset` modes ### `--soft` ```bash git reset --soft HEAD~1 ``` - undoes the commit - the changes stay in the staging area - the working files do not change ### `--mixed` (default) ```bash git reset HEAD~1 ``` - undoes the commit - the staging area is cleared - the changes stay in the working directory ### `--hard` ```bash git reset --hard HEAD~1 ``` - undoes the commit - clears the staging area - removes the changes from the working directory leads to data loss --- ## What `git reset` does NOT do - it does not create new commits - it is not intended for public branches --- ## Important rule `git reset` rewrites history. Safe to use **only for local, unpublished commits**. --- ## Key phrasing for an interview > `git reset` moves the branch pointer to another commit and, depending on the mode, updates the staging area and the working tree, thereby undoing commits and changing the history.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.