Several commits previously I had some javascript working one way. Over the course of several commits I now have it working another way. I would like to look at the file as it was several commits ago because I might want to use aspects of it in the new javascript. However I don't want to revert my current file to exactly what it was. I just want to literally open the old file, have a look around it and maybe copy and paste some code from it into the new file.
How do I retrieve a copy of the file from a previous commit without overwriting the most recent version?
Simply redirect the output of git show
to a file.
git show *SHA-of-old-commit*:*filename* > newfilename
eg:
git show 7c4eacc:main.cpp > main.cpp.old
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With