---
type: snippet
id: g4togielbs9vkxus
title: How to Reset a Single File in Git
url: >
  https://www.jakubpelak.com/snippets/how-to-reset-single-file-in-git
section: snippets
tags:
  - Git
  - CLI
published_at: 2025-07-15
---

# How to Reset a Single File in Git

If you've made changes to a file and want to discard them, you can use `git checkout` to restore it to the version from the last commit. This is useful when you want to undo changes that haven't been staged yet.

```sh
git checkout -- <file>
```

To restore a file from a different branch, you can use:

```sh
git checkout <branch> -- <file>
```
