I've found a patched file in a old forum thread of a file for which I've a git repository.
I'd like to find out what version of the file was used (probably the one with less diffstat?)
I'm still a git newbie.
Is there already some git builtin for a check like this? If not, how do I list each changed version of the file and checkout a particular version? (There's only the master branch)
If you open the patch file (assuming it was generated using git format-patch), you will find a line like:
diff --git a/file.py b/file.py
index a344535..477ede1 100644
Here, a344535
, 477ede1
are both commit id's (they are the shortened SHA/commit ids).
To checkout the file version from which the patch was generated, do a checkout on the commit
git checkout a344535
And now, you can do a gitk
(might need to install with apt-get
) on the repository to check further history.
Note: the git checkout <SHA>
above will take you to a detached head state, so don't forget to do a git checkout master
once you want to start working on your repo again.