I was recently asked how to get some old 32bit support files for linux we used to keep in our repositories before we dropped 32 bit support (not that we ever officially supported 32b, but anyways). This brought up how to get at these historical files that are in our repository history, but removed from master years ago:
The PR above removes a bunch of these files, and I was asked how to get access to them once again. Well, with git
, it is quite easy. As you can see from the PR commits, the SHA for this change was 1fec1f0.
So how do we get to this point in the repository history and then back up to the state just before this commit when those files existed? I’ll show you!
First, you must be using git
for source control management, not just the downloaded code from github.
Step 1: Checkout the commit where things were changed
To checkout the state of the repository exactly where something happened, you get the commit SHA and run this command:
git checkout 1fec1f0
This will rewind the repository to this exact commit in the history. But this is not enough, because now we are at the state right after the files were removed, and we need to back up one more step to a state where they existed.
Step 2: Go back to before the change
There are several ways to do this. I’m going to show you one. First we’ll look at the last two commits at this point in the history with the git log
command.
git log -2
This will show the last two commits and their log statements:
commit 1fec1f0b60112ac6fb8c01dc7bc10e89bca992b3
Author: DavidRagazzi <david_ragazzi@hotmail.com>
Date: Sun Dec 21 13:28:15 2014 -0200
Remove linux32 external libraries
commit a645bb993150487ff6a19bc89082da5538d74a18
Author: Matthew Taylor <matt@numenta.org>
Date: Mon Dec 29 12:01:14 2014 -0800
Continuing work on 0.0.11-dev
The 2nd commit in the list is the one that happened right before the commit that removed the files we want, and now we know the SHA for that commit is a645bb9
. So all we need to do is checkout the repository with that commit SHA:
git checkout a645bb9
Now you have access to the files that were deleted in the PR above in your local directory. Just ls external
to see all those linux 32 support files.
I hope this is helpful!