Languages
[Edit]
EN

Git - revert single file

5 points
Created by:
Xitiz
2195

In this short article, we would like to show how in Git revert single file to the last version using Bash (or any other command line).

Quick solution:

 

Practical example

Edit

Let's suppose, we have modified few files and we want to revert only src/components/button.tsx.

Use one of the below commands:

Where: HEAD and -- indicate last version.

 

Full example:

We can see the line with modified:   button.tsx disappeared - button.tsx is restored to the last version.

 

Alternative titles

  1. Git - reset single file
  2. Git - recover single file
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Git

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join