A
A
Alex Clean2022-04-03 16:28:43
git
Alex Clean, 2022-04-03 16:28:43

How to rollback file changes with Git?

I finished the main page on the site, after which I wrote the standard code for the commit. I started to type the next page of the site, for example, shop.html. I created different files, and after 20 minutes I realized that I had done some kind of goo and I want to return to the last commit. I enter, for example: git checkout 542s4de- commit log for an example. And gives me:

error: Your local changes to the following files would be overwritten by checkout:
        index.html
Please commit your changes or stash them before you switch branches.

I understand that I need to commit the changes first and then switch, but I don't want to commit my mistakes. I just want to go back to the last commit.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2022-04-03
@WebNerd

Read the Git Book
Specific to your case: git reset --hard
WARNING! This command will destroy all changes in uncommitted files.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question