[Git] Roll back a file to a certain version

first step:

Enter the following command in the command line:

git log index.php

You will get an interface similar to the following:

The second step:

Copy the hash that requires a rollback version, for example, if you want to roll back to 5469ae290695a23ac3ef3c47636ea4cb88bd125a, copy the version number

third step:

Checkout the corresponding version.

The format is git checkout <hash> <filename> , input in the command line

git checkout 5469ae290695a23ac3ef3c47636ea4cb88bd125a index.php

 

the fourth step:

The version after commit checkout.

git commit -m "revert to previous version"

 

Note: Don’t forget to add file attributes in the third step, namely src/main/main.c

Guess you like

Origin blog.csdn.net/I_lost/article/details/103902244