Git: restore file(s)

To restore file from one of the previous commits or tags do this:

List commits:
git log --oneline

Switch to old commit (detached HEAD state):
git checkout (commit hash or tag)

Copy old file:
cp file1.txt file1.restored

Switch back to current version:
git checkout master

Add restored files:
git add file1.restored

Commit with restored files
git commit -m "Commit with restored files"

Push changes:
git push origin master

 

Оглавление цикла статей по Git.

Надеюсь озвученная информация будет полезной, а если нужна будет помощь — используйте форму на главной странице моего сайта.