Re: How to query the version of a file?
- From
- Todd A. Jacobs <tjacobs@si2services.com>
- Date
- Aug 25, 2010, 13:27 UTC
- Message-ID
- <AANLkTi=_LaHnuZ7AYDW_TCD7fhSFFdcm_hX3GHRyvwEi@mail.gmail.com>
- In-Reply-To
- <AANLkTi=upbiD5EBumxNxG0YvSRZN0mDfvu7LeU0y0Zpw@mail.gmail.com>
On Wed, Aug 25, 2010 at 2:33 AM, Edmond Halley <halleyinvent@gmail.com> wrote:
Show 6 quoted lines
> I have a standalone repository. > File a.cpp has 3 versions. > For example, I checked out version2(HEAD^). >> git checkout HEAD^ a.cpp > After a few days, I forget which version I have checked out. > Is there a git command that can query which version is checked out?
There may be an easier way to do this, but the way I do it is (sort of) documented in http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#Finding-comments-With-given-Content (should be "commits" instead of "comments", but oh well!) and can be tweaked to suit yourself:
git log --raw --abbrev=40 --pretty=oneline |
grep -B 24 `git hash-object a.cpp`There may be other, and possibly more efficient, ways to do this, but it generally works for me.