How to revert to earlier file commit with git?

Am I working on a file in which my current commit turned out to be bad, and I want to revert to earlier commits for a specific file?

I did a search, it looks like no one answered a similar question (how to undo changes to a file in a previous commit in git) ....

Hope a simple answer?

+3
source share
3 answers
git checkout <commit-id> file(s)

It will be easy to overwrite, so be careful with your files, which may span multiple files at once. For help, you can check the messages git logwith the necessary files as a filter:

git log <file>

, <file>.

+3

git reset <commit hash> <filename>

+3

, , , , , , git , . , , , , , .

, , , .

, , (, git gui), , .

0

Source: https://habr.com/ru/post/1767894/


All Articles