Checking out old versions of files in git
15 May, 2015
Here’s another useful alias if you’re using git. Sometimes you want to recover a file which has been deleted, or restore an old version of a single file. Or, you might want to grab a file from a different branch. This alias will let you do that:
|
|
Use it like this:
|
|
|
|
|
Note that this will write the file out to its actual location (overwriting whatever’s there), so don’t run it if you have local modifications to that file, unless you don’t mind those modifications getting overwritten!
If you are using git-media, or something similar, you need to pipe the file through the filter. I set up another alias to do this:
|