1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-06-08 10:06:01 +02:00
tldr/pages/common/git-reset.md
Managor 0e8893e1ba
git*: refresh pages (#16372)
Co-authored-by: Juri Dispan <juri.dispan@posteo.net>
Co-authored-by: CleanMachine1 <78213164+CleanMachine1@users.noreply.github.com>
Co-authored-by: Sebastiaan Speck <12570668+sebastiaanspeck@users.noreply.github.com>
2025-05-05 09:12:13 +03:00

33 lines
973 B
Markdown

# git reset
> Undo commits or unstage changes, by resetting the current Git HEAD to the specified state.
> If a path is passed, it works as "unstage"; if a commit hash or branch is passed, it works as "uncommit".
> More information: <https://git-scm.com/docs/git-reset>.
- Unstage everything:
`git reset`
- Unstage specific file(s):
`git reset {{path/to/file1 path/to/file2 ...}}`
- Interactively unstage portions of a file:
`git reset {{[-p|--patch]}} {{path/to/file}}`
- Undo the last commit, keeping its changes (and any further uncommitted changes) in the filesystem:
`git reset HEAD~`
- Undo the last two commits, adding their changes to the index, i.e. staged for commit:
`git reset --soft HEAD~2`
- Discard any uncommitted changes, staged or not (for only unstaged changes, use `git checkout`):
`git reset --hard`
- Reset the repository to a given commit, discarding committed, staged and uncommitted changes since then:
`git reset --hard {{commit}}`